tableviewcell

Get .xib height to use it in the heightForRowAtIndexPath function

旧巷老猫 提交于 2020-01-06 04:57:05
问题 I have created a custom .xib that contains a TableViewCell that contains a UIImageView And UILabel . I want to know TableViewCell height in the .xib file, not to set it manually in heightForRowAtIndexPath function. Also is there a property of UIImage to have the height of the TableViewCell when i change it by hand in the .xib file? 回答1: UITableViewCell is actually a UIView, so when you load it from xib the frame property can help you: cell.frame.size.height 来源: https://stackoverflow.com

Swift : How can I fill the cell when the data is empty?

浪尽此生 提交于 2020-01-06 03:37:06
问题 I'm using tableview. Sometimes my datas getting error, because it is empty data. When I get empty data, I want to return 1 or more cell and show empty data information texts like "No data available!". Code : func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { var a:Int = 0 if segmentControl.selectedIndex == 0 { a = 8 return a }else if segmentControl.selectedIndex == 1{ a = 4 return a }else if segmentControl.selectedIndex == 2{ a = 2 return a }else if

How to reload tableview after delete item in cell Swift 2

亡梦爱人 提交于 2020-01-02 07:35:07
问题 I have a list of accounts in a TableView . After I press a button, an item is deleted. So far so good. How to refresh tableView after deletion? Please find the below screenshot for more information. TableView is in another ViewController, the button to delete is in a ViewControllerCell class cellAccount: UITableViewCell { @IBOutlet weak var imgAccount: UIImageView! @IBOutlet weak var lblNomeAccout: UILabel! @IBOutlet weak var btnDeletar: UIButton! @IBAction func btnDeletar(sender: AnyObject)

How to access the content of a custom cell in swift using button tag?

我是研究僧i 提交于 2019-12-27 11:12:32
问题 I have an app that has a custom button in a custom cell. If you select the cell it segues to the a detail view, which is perfect. If I select a button in a cell, the code below prints the cell index into the console. I need to access the contents of the selected cell (Using the button) and add them to an array or dictionary. I am new to this so struggling to find out how to access the contents of the cell. I tried using didselectrowatindexpath, but I don't know how to force the index to be

How to access the content of a custom cell in swift using button tag?

妖精的绣舞 提交于 2019-12-27 11:12:08
问题 I have an app that has a custom button in a custom cell. If you select the cell it segues to the a detail view, which is perfect. If I select a button in a cell, the code below prints the cell index into the console. I need to access the contents of the selected cell (Using the button) and add them to an array or dictionary. I am new to this so struggling to find out how to access the contents of the cell. I tried using didselectrowatindexpath, but I don't know how to force the index to be

Short Term Memory Between VCs in Swift

耗尽温柔 提交于 2019-12-25 09:59:38
问题 The short version is: Do the values of a VC's variables stay in tact during the modal presentation and dismissal of another VC? When the second VC is dismissed, are the original VC's variables still equal to their last values? Details, If Needed I have a viewController where a table cell is selected. The contents of that cell are then pulled out and passed onto an editor viewController like this: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { //Segue to mainVC

Share object state between View Controllers in IOS development

怎甘沉沦 提交于 2019-12-25 09:06:37
问题 My app has two tabs on a main TabViewController. The first tab shows a list of the fruits I like. The second tab send a request to an api while you type, searching for fruits with the name searched. If the user clicks on any fruit, I'll show a fruit detail view, where It's possible to like the fruit (if it's already liked, you can unlike). Now, I'm trying to achieve something like: The user searchs for a fruit The user likes the fruit The user navigates back to the list List shows the fruit

Swift - Constraints issue in expandable TableViewCell

梦想与她 提交于 2019-12-25 08:14:06
问题 I'm creating an expandable cell with labels and picker view xib Cell Implementation class PickerViewCell: UITableViewCell { @IBOutlet weak var detailLabel: UILabel! @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var height: NSLayoutConstraint! @IBOutlet weak var picker: UIDatePicker! var isExpanded:Bool = false { didSet { if isExpanded == false{ self.height.constant = 0.0 self.picker.hidden = true } else{ self.height.constant = 200.0 self.picker.hidden = false } } } override func

Tableview button selection wrong after search

断了今生、忘了曾经 提交于 2019-12-25 05:47:05
问题 I have a UIButton in the UITableViewCell . When a UIButton is tapped, I'm saving the tapped button tag in the array. So when I search within the UITableView using the UISearchController , I'm getting the desired output, but the selected button is selected within the wrong cell. Pic 1 - Button selected and before search pic 2 - After the search In the pic 1, I have selected the button that belongs to "room 1", but after the search, as you can see in the pic 2, the output is correct, but the

Passing information to a custom TableViewCell - Swift

こ雲淡風輕ζ 提交于 2019-12-25 04:32:36
问题 The problem is this: I tried many ways to pass down information to a ViewController1 from a SecondViewController. In this first ViewController1 I have a tableView, and in this tableView, each cell will receive an image and a label. What I want to do is, in the SecondViewController, I will write something in a textField and pick some random image and display it in the ViewController1. Could someone tell me how to do it? I tried delegates, dequeuereusablecell and the data won't display in the