Search bar area is empty when a tallish table cell is deleted
| Originator: | robotspacer | ||
| Number: | rdar://16850565 | Date Originated: | 08-May-2014 02:47 AM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 7.0 through 7.1.1 |
| Classification: | Other Bug | Reproducible: | Always |
Summary: On iOS 7, if a table has tallish rows, the search bar is out of view, and the last row that makes the table scroll is deleted, the area for the search bar comes into view, but the search bar itself is missing. It's a little hard to explain so I've attached a video—it's very easy to reproduce. Steps to Reproduce: 1. Create a new project with a UITableViewController. The attached sample app uses the "Master-Detail Application" template. 2. Add a search bar to the template. 3. Make the row heights taller. anywhere from 60 to 100 points seems to work fine for me. I'm guessing it just needs to be taller than the search bar. 4. Run the app. 5. Add enough cells to the table so that it starts to scroll. 6. Make sure the search bar is off the screen. Either the first table cell or the last one should be partially, but not entirely visible. 7. Delete a row. Expected Results: The area containing the search bar should either not come into view, or it should come into view and the search bar should be visible. Actual Results: The table scrolls is a kind of awkward way, so that the last table cell is at the very bottom of the screen. That means the search bar area is now partially on screen, but the search bar itself is not drawn. If the attached sample app, I've made the table background blue to better illustrate this: you can see blue where the search bar should be.
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!
Workaround
In case anyone else stumbles across this and is trying to figure out how to fix it, here's my solution. After deleting a row, I do something like this:
if (searching == NO) { // Might also want to limit it to iOS 7 here // These next two lines will depend on the app, but figure out the total height of all the rows in an efficient way NSInteger count = [tableView numberOfRowsInSection:0]; CGFloat contentHeight = count * 96.0; CGFloat insetTop = self.tableView.contentInset.top; CGFloat tableHeight = tableView.frame.size.height - insetTop; CGFloat searchHeight = self.searchDisplayController.searchBar.frame.size.height; if (contentHeight < tableHeight && contentHeight + searchHeight > tableHeight) { tableView.contentOffset = CGPointMake(0.0,-insetTop); } }