2016-08-03 95 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]; 
} 
相關問題