Ios 设置rootViewController时向VC发送无法识别的选择器'InhibitationRotationAnimation'
启动应用程序后,BaseVC初始化。在BaseVC中,我将验证用户是否已登录。如果为true,我的应用程序将使用以下命令跳转到主选项卡栏控制器:Ios 设置rootViewController时向VC发送无法识别的选择器'InhibitationRotationAnimation',ios,swift,cocoa-touch,uiapplication,Ios,Swift,Cocoa Touch,Uiapplication,启动应用程序后,BaseVC初始化。在BaseVC中,我将验证用户是否已登录。如果为true,我的应用程序将使用以下命令跳转到主选项卡栏控制器: UIApplication.sharedApplication().windows.last?.rootViewController = tabbarController UIApplication.sharedApplication().windows.last?.rootViewController = navi 如果没有,我的应用程序将使用以
UIApplication.sharedApplication().windows.last?.rootViewController = tabbarController
UIApplication.sharedApplication().windows.last?.rootViewController = navi
如果没有,我的应用程序将使用以下命令跳转到登录导航控制器:
UIApplication.sharedApplication().windows.last?.rootViewController = tabbarController
UIApplication.sharedApplication().windows.last?.rootViewController = navi
上面的代码按照我的要求正确运行。但在登录导航控制器中,在用户输入正确的用户名和密码后,我希望应用程序使用与上面相同的代码跳转到主tabbar控制器:
UIApplication.sharedApplication().windows.last?.rootViewController = mainController
但我总是会被错误迷住:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[Myapp.MyappMainTabbarVC inhibitRotationAnimation]:
unrecognized selector sent to instance 0x7ff15b205ec0'
为什么?您确定第一次和第二次传递的是同一个对象吗?首先要传递
tabbarController
,然后要传递mainController
到窗口的rootViewController
属性。@BellAppLab对于名称的误导表示抱歉。我确信这两个名字是同一个物体。