r******n 发帖数: 81 | 1 我设计的一个app,最外面是一个UITabView,第一个Tab里放了一个UITableView,用来
显示一个列表,点击列表的一项,可以打开详细的View。一切都是好好的,从tab到
list到detail,然后返回list。
后来吧,我就加了一个search bar controller在那个TableView里面。先开始是search
的results里面的cell不能点击,后来看了网上的资料后加了关于segus处理的代码好了
,但是现在有个问题,就是从detail返回的时候会crash,报告的错误是navigation
subtree corupted。感觉是detail view被push了多次,但是又没有找到是哪里。
有没有遇到过相同情况的? |
z*******n 发帖数: 1034 | 2 样例寄出来观摩观摩
search
【在 r******n 的大作中提到】 : 我设计的一个app,最外面是一个UITabView,第一个Tab里放了一个UITableView,用来 : 显示一个列表,点击列表的一项,可以打开详细的View。一切都是好好的,从tab到 : list到detail,然后返回list。 : 后来吧,我就加了一个search bar controller在那个TableView里面。先开始是search : 的results里面的cell不能点击,后来看了网上的资料后加了关于segus处理的代码好了 : ,但是现在有个问题,就是从detail返回的时候会crash,报告的错误是navigation : subtree corupted。感觉是detail view被push了多次,但是又没有找到是哪里。 : 有没有遇到过相同情况的?
|
r******n 发帖数: 81 | 3 这个问题已经解决了。我发现网上的好多教程都是错的,比如这个
http://www.raywenderlich.com/16873/how-to-add-search-into-a-tab
有个函数,例子是这样的:
#pragma mark - TableView Delegate
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(
NSIndexPath *)indexPath {
// Perform segue to candy detail
[self performSegueWithIdentifier:@"candyDetail" sender:tableView];
}
但我发现必须要这样才行:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(
NSIndexPath *)indexPath {
NSLog(@"lincai: %@ *** %@ *** %d", tableView,self.
searchDisplayController.searchResultsTableView, [indexPath row]);
if (tableView == self.searchDisplayController.searchResultsTableView) {
[self performSegueWithIdentifier:@"wordDetail" sender:tableView];
}
}
【在 z*******n 的大作中提到】 : 样例寄出来观摩观摩 : : search
|
z*******n 发帖数: 1034 | 4 comments 里有说有问题,官方不会没例子把
【在 r******n 的大作中提到】 : 这个问题已经解决了。我发现网上的好多教程都是错的,比如这个 : http://www.raywenderlich.com/16873/how-to-add-search-into-a-tab : 有个函数,例子是这样的: : #pragma mark - TableView Delegate : -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:( : NSIndexPath *)indexPath { : // Perform segue to candy detail : [self performSegueWithIdentifier:@"candyDetail" sender:tableView]; : } : 但我发现必须要这样才行:
|