Since iOS 8 I'm experiencing a weird issue with a table view/UISearchBar setup and wondered if others have experienced a similar issue or can point to what, if anything, I might be doing wrong. The broad situation:
- I have a UITableViewController with a UISearchBar within it, set up in the app's Storyboard
- the table view has a custom cell, again, set up in the Storyboard
- selecting a table row triggers a segue to another view
- performing a search, tapping a row from the search results to segue to the other view, then navigating back again, triggers various issues.
"The issues" are that if I implement cellForRowAtIndexPath as follows:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MyCell *cell = (MyCell *) [self.tableView dequeueReusableCellWithIdentifier:@"MyId" forIndexPath:indexPath];
...
in other words by specifying the path to dequeueReusableCellWithIdentifier, then this results in a BAD_ACCESS or assertion failure in iOS 8 (but not iOS 7). Specifically, either an assertion failure or BAD_ACCESS occurs on calling dequeueReusableCellWithIdentifier under the circumstances mentioned above, i.e. when, with a search active, you segue from one of the cells in the results table to another view and then segue back again.
Now, I can stop the error occurring by just calling:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MyCell *cell = (MyCell *) [self.tableView dequeueReusableCellWithIdentifier:@"MyId"];
...
without passing in the indexPath. This then works without an error as such, but on segueing back to the table view with search results, a weird display issue occurs whereby layered underneath the search results, there appear to be the separators of a "ghost" table, almost as though the system is trying to render one table directly on top of another (but cellForRowAtIndexPath isn't being called for each table, only for the search results table as expected).
I get the same problem whether the segue is attached to the cell or table view controller (so in the latter case, I implement didSelectRowAtIndexPath to manually trigger the segue).
So: (a) can anyone point to something I might be doing wrong to cause these issues, or (b) point to a bare-bones working example of a table view controller with UISearchBar where the table cells segue to another view? I'm surprised I'm getting so many issues as implementing a searchable table with detail views must be a common, boring thing that people do all of the time, no?
Sample project exhibiting the iusse: http://www.javamex.com/DL/TableTest.zip