uitableview

Swift tableview cell auto height with auto height label

限于喜欢 提交于 2021-01-29 02:58:08
问题 I have some problems with swift. Need to make tableview and in every cell to have image with text inside. This is what i made so far: First problem: Label should be auto height, now it breaks string.. Second problem: Image needs to be auto height too, and to depends on label height. Third problem: Row needs to be autoheight depending on its inside. TableViewController code: @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() tableView.rowHeight =

Smoothly scrolling tableview up by fixed constant when keyboard appears so last cells are still visible

不羁岁月 提交于 2021-01-28 21:11:57
问题 When the keyboard appears, I am shifting the bottom-most view up by a constant. But due to this the hight of the UITableView also reduces and the cells that were previously visible are no longer visible. What I want to do is scroll the table view up by a height equal to the keyboard's height so that at least the last messages will be visible like they were before the keyboard appeared. The last yellow cell that was half-visible in the image on left should be visible like that on the right too

Is weak self needed for table view cell button closure

吃可爱长大的小学妹 提交于 2021-01-28 11:34:51
问题 In trying to avoid retain cycles, would using [weak self] in in a UITableViewCell button action be necessary? Example: in ViewController's cellForRow cell.buttonAction = { (cell) [weak self] in self.someFunction() } in TableViewCell class var buttonAction: ((UITableViewCell) -> Void)? @IBAction func buttonPressed(_ sender: Any) { buttonAction?(self) } 回答1: The key line to think about is: var buttonAction: ((UITableViewCell) -> Void)? You are offering to store a function long-term in an

expandable drop down inside tableview in swift4

好久不见. 提交于 2021-01-28 10:23:44
问题 I tried, expandable drop down inside tableview in swift4 but not worked my below code. if i changed custom model class to String it is working. my requirement use below custom model class. please check my below code. class ExpandViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, ExpandableHeaderViewDelegate { var empDetails = [EmpWorking]() var hiredDetails = [Hired]() @IBOutlet weak var tableView: UITableView! var sections = [SectionData]() override func

Custom UITableViewCell content doesn't move when editing

限于喜欢 提交于 2021-01-28 08:41:44
问题 I'm working on a Custom UITableViewCell with editing. When I enter editing mode, the label are not moved properly. This is the code in the .m file - (id) init { self = [super init]; self.driverLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; self.lastMessageLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; [self.contentView addSubview:self.driverLabel]; [self.contentView addSubview:self

Increment Label Value with UIStepper in UITableViewCell

我与影子孤独终老i 提交于 2021-01-28 03:06:46
问题 I want to be able to use a UIStepper that is located in each tableview row. I would like each UIStepper to update a label in the same tableview row that the UIStepper is in. The code that I am trying is as follows func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cartListCell = tableView.dequeueReusableCell(withIdentifier: reuseCartListingCellIdentifier, for: indexPath) as? CartListingItemTableViewCell cartListCell?.UI_STEPPER_NAME.value =

Select the UITableView on UICollectionView selection

旧时模样 提交于 2021-01-28 01:47:52
问题 I have a UICollectionView inside UITableViewCell . When I select the a tableView row, I do not want the didSelectItemAtIndexPath: method of UICollectionView to get called. Instead I want didSelectRowAtIndexPath: method of UITableView to get called. How would I call didSelectRowAtIndexPath: in didSelectItemAtIndexPath: ? 回答1: Set collectionView.allowsSelection = NO to disable selection. OR in the didSelectItemAtIndexPath method, grab the UITableViewCell and call the delegate which is the table

UITableView scroll to bottom from current position

老子叫甜甜 提交于 2021-01-27 18:46:27
问题 How can I scroll to last row in tableview from current positon, because I have tried this solution: self.tableView.scrollToRow(at: lastIndex.last!, at: .bottom , animated: false) let numberOfSections = self.tableView.numberOfSections let numberOfRows = self.tableView.numberOfRows(inSection: numberOfSections-1) if numberOfRows > 0 { let indexPath = IndexPath(row: numberOfRows-1, section: (numberOfSections-1)) self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: animated) } and it

Adding Constraints to UITableViewCell

谁说我不能喝 提交于 2021-01-27 18:10:47
问题 I am having trouble getting constraints to work on my UITableViewCell . The cell currently has 2 text fields and a button with an image. iPhone X Storyboard Currently without constraints the cell content doesn't change position no matter which device I test it on. For instance on an iPad it looks like this iPad storyboard When I add constraints it looks like it is going to work, but then when I run the app the content is all screwed up. Here are screenshots of what it looks like with

UITableViewCell top shadow is covered by UITableView header view

て烟熏妆下的殇ゞ 提交于 2021-01-27 17:17:39
问题 I have a UITableView with a custom HeaderView (added via storyboard). I want to put a drop shadow on the first cell in the table view. Unfortunately, the header view covers the shadow. I am making the shadow in cellForRowAtIndexPath with: [cell setClipsToBounds:NO]; [cell.layer setMasksToBounds:NO]; [cell.layer setShadowOffset:CGSizeMake(0, 2)]; [cell.layer setShadowColor:[[UIColor blackColor] CGColor]]; [cell.layer setShadowRadius:4.0]; [cell.layer setShadowOpacity:1.0]; [cell.layer