0

我有一个MapViewController,封装是Segue公司到一个UIViewController都放在一个故事板一个UITableViewController一个UINavigatioController一个UINavigationController。在地图上点击它时有一个按钮我希望调用UITableViewController并能够打开UIViewController。呼叫从一个MapViewController

如果我叫

[self presentViewController:self.tableViewController animated:NO completion:nil]; 

的TableViewController显示,但在披露指标点击抛出异常时:

“找不到赛格瑞‘showApartmentDetails’导航控制器。只有当源控制器由UINavigationController实例管理时,才能使用推塞网。“

创建类型的UINavigationController的属性和使用

self.navigationController = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"myNavigationController"]; 
[self.navigationController pushViewController:self.tableViewController animated:NO]; 

什么都不做初始化它!

请告知我该如何调用导航器?

回答

0

问题是因为

[self presentViewController:self.tableViewController animated:NO completion:nil]; 

需要出示该处理tableViewControllerUINavigationController。因此,您需要将故事板中的UINavigationController链接到名为UINavigationController *tableViewNavigationController的插座,其编号为MapViewController

[self presentViewController:self.tableViewNavigationController animated:NO completion:nil]; 

或刚刚从按钮,在MapViewController在故事板上添加一个模式SEGUE到UINavigationController

+0

你是什么意思tableViewNavigationController是什么类型的属性呢? self是mapviewcontroller它没有presentViewController接口'没有可见的@interface'MapViewController'声明选择器'pushViewController:animated:' –

+0

@liva我编辑了我的解决方案。这个属性应该是包含'tableViewController'的'UINavigationController'。 –

+0

创建一个插座,我需要创建我自己的类,从UINavigationController派生的,什么也不做,而是我用这个'self.navigationController =(UINavigationController *)[self.storyboard instantiateViewControllerWithIdentifier:@“myNavigationController”];' –