【发布时间】:2014-12-10 04:37:38
【问题描述】:
我有一个 UISearchDisplaycontroller,我必须将信息推送到文本字段并需要将其链接到导航视图控制器。
这是我的代码 -
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showRecipeDetail"]) {
NSIndexPath *indexPath = nil;
Recipe *recipe = nil;
if (self.searchDisplayController.active) {
indexPath = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
recipe = [searchResults objectAtIndex:indexPath.row];
} else {
indexPath = [self.tableView indexPathForSelectedRow];
recipe = [recipes objectAtIndex:indexPath.row];
}
RecipeDetailViewController *destViewController = segue.destinationViewController;
destViewController.recipe = recipe;
}
}
【问题讨论】:
-
其中有什么问题?你没有得到正确的索引路径?
-
问题是当我链接到导航视图时,它说不支持推送到导航视图。
-
可能是您的导航层次结构错误。你已经导航到你的视图控制器并再次推送到导航控制器。最后是你的导航在错误的地方。
-
您在视图控制器之前有导航控制器,您从中推送到下一个 vc