uitableview

Adding Buttons to Static TableView Headers with Swift

眉间皱痕 提交于 2021-02-08 11:50:30
问题 I am trying to add UIControls to static TableViewHeaders in iOS using swift. The goal is build on top of the default appearance so the UI will match default UI elements going forward. I found a great example of modifying the appearance of existing elements, but nothing on adding new ones. My specific goals are: "Select All" functionality to quickly mark all rows in a section as "checked" (could be a checkmark accessory, UISwitch, etc) "Show/Hide" functionality to allow a single View to

When user uses back button to UITableView to scroll to last selected row

青春壹個敷衍的年華 提交于 2021-02-08 10:31:01
问题 I have a tableView with about 200 rows. When a user selects a row to view the details and later hits the back button, the tableView always returns to the top of the table. I would like to set up the tableView to force the tableView to auto scroll to the row in which the user last selected. How to do this? 回答1: I would suggest storing selected NSIndexPath in the didSelectRowAtIndexPath method (when user presses on a cell). Then in viewWillAppear or viewDidAppear method (in view controller

'NSInternalInconsistencyException', reason: 'Requested the number of rows for section (0) which is out of bounds.'

↘锁芯ラ 提交于 2021-02-08 08:48:21
问题 I'm getting this error when I try to run my app on iOS 13, older versions was working fine. 'NSInternalInconsistencyException', reason: 'Requested the number of rows for section (0) which is out of bounds.' This is what I presume that is causing the exception override func reloadData() { super.reloadData() let rows = self.numberOfRows(inSection: 0) // what I know is that this line is causing the exception if (rows > 0) { if placeholderStackView != nil { self.placeholderStackView

swift 3 ios tableview scroll by cell

半城伤御伤魂 提交于 2021-02-08 07:25:23
问题 I created a tableview and it works normally as intended. However, I would like to change the scrolling such a way where the user can only scroll one cell at a time so that, there is never a time where the cell is cut in half.. This is an example: http://imgur.com/ffmk0jP So basically i do not want the default scrolling.. i would like it to be scrolled one cell at a time to constantly remain with the view of the original state.. Is there a way? 回答1: how about this ?

NSFetchedResultsController - reversed NSIndexPath with multiply sections and pagination

不想你离开。 提交于 2021-02-08 04:18:11
问题 To simplify my example, I develop ChatViewController where I need to display messages grouped into sections (one section for one day). I can load more messages swiping UITableView down. I need a pagination here. Messages are displayed from the oldest (top) to the latest (bottom of the table). The obvious is that I need to fetch messages sorted by createdAt property DESCENDING . So this is how I setup my NSFetcheResultsController on viewDidLoad() : private func setupFetchedResultsController()

Dynamic height for a UITableView based on a dynamic collection view

荒凉一梦 提交于 2021-02-08 02:01:12
问题 I have to add a UICollectionView inside a UITableViewCell . The collectionView can have a different number of items. So the collectionView should adjust properly inside the tableView . I have implemented this inside my Project: https://github.com/vishalwaka/DynamicCollectionViewInsideTableViewCell In my case, the height of the cell is not being the adjusted after the height of the collectionView is set. How can I set the collectionView to not be scrollable and also show all content inside the

Dynamic height for a UITableView based on a dynamic collection view

☆樱花仙子☆ 提交于 2021-02-08 02:00:04
问题 I have to add a UICollectionView inside a UITableViewCell . The collectionView can have a different number of items. So the collectionView should adjust properly inside the tableView . I have implemented this inside my Project: https://github.com/vishalwaka/DynamicCollectionViewInsideTableViewCell In my case, the height of the cell is not being the adjusted after the height of the collectionView is set. How can I set the collectionView to not be scrollable and also show all content inside the

Custom cell is not correctly drawn when a row is inserted using insertRows(atPaths) method

纵然是瞬间 提交于 2021-02-07 23:29:32
问题 I have a custom cell, which is subclass of UITableViewCell , call it Cell . I have added a UITableViewCell through a storyboard to a tableview ( tableview's content is set to Dynamic Prototypes) and have set cells class to Cell . Also I have set the reuse identifier appropriately. The cell is defined in xib , and I load it like this: self.tableView.register(UINib(nibName: "Cell", bundle: nil), forCellReuseIdentifier: "CellIdentifier") The cell itself has only two elements, and those are, one

Custom cell is not correctly drawn when a row is inserted using insertRows(atPaths) method

二次信任 提交于 2021-02-07 23:28:29
问题 I have a custom cell, which is subclass of UITableViewCell , call it Cell . I have added a UITableViewCell through a storyboard to a tableview ( tableview's content is set to Dynamic Prototypes) and have set cells class to Cell . Also I have set the reuse identifier appropriately. The cell is defined in xib , and I load it like this: self.tableView.register(UINib(nibName: "Cell", bundle: nil), forCellReuseIdentifier: "CellIdentifier") The cell itself has only two elements, and those are, one

How to configure threshold/distance when swiping on UITableViewCell

限于喜欢 提交于 2021-02-07 23:23:28
问题 I have swipeable tableview cells. The intention is to let the user swipe rows left or right completely (swipe out completely), and the swiped row gets removed from the table (like how Inbox by Gmail works). Everything works fine, but I had a question. func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { let swipeRightAction = UIContextualAction(style: .destructive, title: "", handler: { (ac:UIContextualAction