开发者

Accessing Data While searchDisplayController is Active

开发者 https://www.devze.com 2023-02-24 00:45 出处:网络
My iPhone app is using Core Data, UISearchBar, UISearchDisplayController, UITableView and UIActionSheet. When no search is being performed, I can determine which row was selected by the user, but if a

My iPhone app is using Core Data, UISearchBar, UISearchDisplayController, UITableView and UIActionSheet. When no search is being performed, I can determine which row was selected by the user, but if a search is active and selection made by the user of a specific row, how does one determine what row was selected by the user?

Example: The following code works without error when NO SEARCH is ACTIVE:

- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex {
    NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
    Event *event = (Event *)[[self fetchedResultsController] objectAtIndexPath:selectedIndexPath];    
    [self showURL:[NSURL URLWithString:event.siteSite] withTitle:@""];

but, the URL is NULL if I use the above method to determine the corresponding "event.siteSite" or URL, while [self.searchDisplayController isActive] equates to TRUE.开发者_如何学Go


When you use a UISearchDisplayController you get a second tableview super imposed on the first. It is that tabelview you have to query to find out which row was selected.

See the UISearchDisplayController Class Reference for details.

0

精彩评论

暂无评论...
验证码 换一张
取 消