Ios 显示查看控制器始终使用UIT ABBARCONTROLLER
我只是添加了TabBarController+NavigationController。在此之前,一切正常,但现在当我从模式调用presentingViewController时,出现以下错误: 由于未捕获异常而终止应用程序 “NSInvalidArgumentException”,原因:-[UITabBarController tableViewListado]:发送到实例的无法识别的选择器 在使用TabBar和Nav控制器时,我应该以不同的方式获得显示控制器,而不是接收预期的对象(ViewController),而是获取“UITabBarController” 没有TabBar/Nav,我使用的是:Ios 显示查看控制器始终使用UIT ABBARCONTROLLER,ios,ios5,Ios,Ios5,我只是添加了TabBarController+NavigationController。在此之前,一切正常,但现在当我从模式调用presentingViewController时,出现以下错误: 由于未捕获异常而终止应用程序 “NSInvalidArgumentException”,原因:-[UITabBarController tableViewListado]:发送到实例的无法识别的选择器 在使用TabBar和Nav控制器时,我应该以不同的方式获得显示控制器,而不是接收预期的对象(ViewC
ViewController *parentView = (ViewController *)[self presentingViewController];
[parentView something];
编辑:
只要发现如果我这样做是可行的,但不要认为这是最好的方法:
ViewController *parentView = (ViewController *)[(UINavigationController *)[((UITabBarController *)[self presentingViewController] ) selectedViewController] topViewController] ;
[parentView something];
我的答案的复印件
发件人:
在iPad上,当呈现的视图控制器的modalPresentationStyle为UIModalPresentationCurrentContext时,必须决定哪个视图控制器应该是呈现的视图控制器的presentingViewController。这将确定显示的视图控制器的视图将替换哪个视图。此决定涉及另一个UIViewController属性DefinePresentationContext(BOOL)。从向其发送presentViewController:animated:completion:的视图控制器开始,我们沿着父视图控制器链走,查找DefinePresentationContext属性为YES的视图控制器。如果我们找到一个,那就是那个;它将是presentingViewController,其视图将被显示的视图控制器的视图替换。如果我们找不到一个,事情就好像显示的视图控制器的modalPresentationStyle是UIModalPresentationFullScreen
TL;DR1.在所需的
presentingViewController上,将definesPresentationContext
设置为true
2.在所需的presentedViewController
上,将modalPresentationStyle
设置为UIModalPresentationCurrentContext
。您需要在调用presentingViewController的位置添加一些代码。检查此项-是,这是我的问题,但我以前读过,但没有真正了解如何纠正这个问题似乎你得到了一个丑陋的解决方案,但我建议你检查你的导航堆栈层次结构,然后它会让你清楚地知道你需要获取什么。你得到的解决方案没有错,考虑到ViewController上的设计,它适用于您的情况。