我的应用程序是以Tab Bar控制器作为RootViewController来设置的,每个Tab都有一个NavigationController。当执行某些操作时,我希望应用程序将一个ViewController推送到屏幕上。这个流程是这样的:当应用程序启动或从后台打开时,它会检查存储的NSDate并将其与当前日期进行比较。如果满足正确的条件,它会显示一个UIAlertView。如果选择了我命名为“Push”的按钮,则运行代码以推送新视图。这就是我需要在AppDelegate中运行它的原因,因为无法保证在后台使用应用程序时会打开哪个选项卡。由于每个选项卡都包含一个NavigationController,所以我认为可以从AppDelegate中运行此函数:
我收到了一个警告信息,内容是
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (alertView.tag == 100) {
if (buttonIndex == 0) {
//Cancel
NSLog(@"Cancel");
}
if (buttonIndex == 1) {
NSLog(@"OK");
[self.tabBarController.selectedViewController pushViewController:self.newView animated:YES];
}
}
}
我收到了一个警告信息,内容是
UIViewController may not respond to -pushViewController:animated
。你有什么其他的建议吗?针对这个问题,我建议您检查一下是否正确导入了相关的库文件,并且确认您正在使用的是正确的视图控制器类。