【发布时间】:2016-09-01 08:20:49
【问题描述】:
我有一个问题。
我有一个 tableView 和 searchController。
当我搜索“C”时,我得到两个名称标题为“C”的数据。
但是当我按下单元格时,detailView 会为我显示错误的信息。
NSArray *searchResult;
UISearchController *mysearchController;
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"getDetail"]) {
if (searchResult != nil) {
DetailViewController *detailViewController = segue.destinationViewController;
NSIndexPath *indexPath = [searchResult..............];
NSDictionary *item = searchResult[indexPath.row];
detailViewController.detailName = item[@"name"];
detailViewController.detailLocation = item[@"address"];
}else{
DetailViewController *detailViewController = segue.destinationViewController;
NSIndexPath *indexPath = self.listTableView.indexPathForSelectedRow;
NSDictionary *item = self.InfoArray[indexPath.row];
detailViewController.detailName = item[@"name"];
detailViewController.detailLocation = item[@"address"];
}
}
}
谢谢!
【问题讨论】:
-
显示完整代码
NSIndexPath *indexPath = [searchResult..............]; -
[theTableViewUsedToShowSearchResults indexPathForSelectedRow]不起作用? -
你能显示执行segue的代码和你的searchResult数组初始化吗?
-
@imbeginner_sorry 如果我的回答,那么请正确感谢我的努力,接受正确的答案。
标签: ios objective-c iphone segue uisearchcontroller