I have a UITableView that on didSelectRowAtIndexPath pushes another UITableView to do a search...
The search view contains a UISearchBar with it's cancel button enabled. If the user taps the cancel button the app crashes with an objc_exception_throw. The console displays...
If, however, the user taps an item in the table view (search results) I am closing the search view and there is no crash. I can't see why the difference as I am popping the search view with the same code...
In the LocationSearchViewController...
In the delegate...
Thanks in advance for any help.
John
Code:
LocationSearchViewController *locationSearchViewController = [[LocationSearchViewController alloc] initWithNibName:@"LocationSearchViewController" bundle:nil];
locationSearchViewController.delegate = self;
UITableViewCell *cell = [myTableView cellForRowAtIndexPath:indexPath];
locationSearchViewController.defaultLocation = cell.detailTextLabel.text;
[[self navigationController] pushViewController:locationSearchViewController animated:YES];
[locationSearchViewController release];
The search view contains a UISearchBar with it's cancel button enabled. If the user taps the cancel button the app crashes with an objc_exception_throw. The console displays...
2011-02-06 22:05:43.960 JetLogger[2381:207] * Assertion failure in -[UISearchDisplayController setActive:animated:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UISearchDisplayController.m:589
If, however, the user taps an item in the table view (search results) I am closing the search view and there is no crash. I can't see why the difference as I am popping the search view with the same code...
In the LocationSearchViewController...
Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([self.delegate respondsToSelector:@selector(locationSearchViewDidDismiss:withLocation:)]) {
[self.delegate locationSearchViewDidDismiss:self withLocation:[tableView cellForRowAtIndexPath:indexPath].textLabel.text];
}
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar{
if ([self.delegate respondsToSelector:@selector(locationSearchViewDidDismiss:withLocation:)]) {
[self.delegate locationSearchViewDidDismiss:self withLocation:@"No results found"];
}
}
In the delegate...
Code:
- (void)locationSearchViewDidDismiss:(LocationSearchViewController *)controller withLocation:(NSString*)location{
if((location != @"") && (location != @"No results found")){
//update the table data
[myTableView reloadData];
}
[self.navigationController popViewControllerAnimated:YES];
}
Thanks in advance for any help.
John