2016-08-03 98 views
0

上下文:我正在使用ArcGIS Runtime SDK在Objective C中创建IOS应用程序。我的根视图控制器是一个地图。我可以选择创建空间书签并在推送到视图上的表格视图中查看它们。我在表视图上有一个UISearchController可以过滤出书签。如果您选择书签而不搜索,则会自动移动到该位置。这是通过弹出所有视图控制器,并加载根视图控制器的书签变量的标志设置为起始范围。关闭UISearchController视图并关闭UITableView以进入根视图控制器

我想与searchController表视图相同的功能。

但是,我要么无法关闭searchController并且书签被放大,或者搜索控制器被解散,并且用户被带回初始表格视图。

我有什么至今:

在上searchController的TableView的didSelectRow方法:

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

//Accept the spatial envelope and save it to the shared variable to be passed to main view controller 
//Now dismiss the searchController and call method to zoom to bookmark 
[self.navigationController dismissViewControllerAnimated:NO completion:^{ 
    //reference to shared instance method 
    [[BookmarksTableViewController sharedBookmark] zoomToBookmark]; 
}]; 

在BookmarksTableViewController.m

-(void)zoomToBookmark{ 
    UIViewController *myController = [self.storyboard instantiateViewControllerWithIdentifier:@"viewController"]; 
    [self.navigationController pushViewController: myController animated:YES]; 
    //clear the navigation stack 
    self.navigationController.viewControllers = [[NSArray alloc] initWithObjects:myController, nil]; 
} 

对我来说,好像这应该工作,但所发生的一切都是UISearchController被解雇,然后表视图不被解雇,我回到了我之前输入搜索文本的位置。

任何想法更好的方式来解除UISearchController或如何返回到我的根视图控制器?

回答

0

希望你的意思是这个答案

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [self dismissViewControllerAnimated:NO completion:nil]; 
} 
相关问题