UITableViewDelegate doesn't formally define important methods called during table reordering
| Originator: | argentumko | ||
| Number: | rdar://21813508 | Date Originated: | 15-Jul-2015 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | iOS 2 – iOS 9 |
| Classification: | Enhancement | Reproducible: | Always |
Summary: UITableView calls several methods on its delegate which are not a formal part of UITableViewDelegate and are not documented: -tableView:willBeginReorderingRowAtIndexPath: -tableView:didEndReorderingRowAtIndexPath: -tableView:didCancelReorderingRowAtIndexPath: These methods provide an important ability for applications to appropriately respond to user reordering the table, which would be otherwise implemented poorly or in a fragile way, leading to bad user experience. These methods are not private API per se, as they *are called* by the SDK, not the other way around, so it's possible to use these methods successfully already, but ideally they should be documented, so that developers would be aware of the possibilities. Steps to Reproduce: 1. Build a simple iOS app with a view controller containing a UITableView and serving as a delegate and data source of that table. 2. Enable reordering of contents of the table by implementing necessary data source and delegate methods. 3. Implement the methods described above in the view controller (the table's delegate). 4. Launch the app and try reordering the rows. 5. The undocumented methods get called at appropriate moments. Expected Results: Described reordering-related methods should be part of the formal UITableViewDelegate protocol and documented. Actual Results: Described reordering-related methods are not part of the protocol, not documented and are arcane word-of-the-mouth magic known only to a few lucky developers. Version: As of iOS 9 Seed 2, these methods still work. Notes: As far as I know, these methods were "available" as long as UITableView was around and still are. The attached project demonstrates how these delegate methods can be used (look at the bottom of MasterViewController.m). Configuration: Any iOS hardware or Simulators Attachments: 'TableViewDelegateDemo.zip' was successfully uploaded.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
(additional information added)
I should mention that the described delegate methods are important mostly because their functionality does not really overlap with available public UITableViewDelegate and UITableViewDataSource methods like -tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: or -tableView:moveRowAtIndexPath:toIndexPath: as they are called at different moments. E.g., "moveRowAtIndexPath" is called prior to completing reordering animations, and performing any actions (like reloading, updating) with the table before these animations are not yet complete will result in issues. -tableView:didEndReorderingRowAtIndexPath: is called when everything is complete, when it's safe to perform other updates.