【发布时间】:2014-06-24 04:26:04
【问题描述】:
我的应用设置了一个标签栏控制器作为RootViewController,每个标签都有一个NavigationController。当执行某些操作时,我希望应用程序将ViewController 推送到屏幕上。其流程是,当应用程序启动或从后台打开时,它会检查存储的 NSDate 并将其与当前日期进行比较。如果满足正确的条件,则会显示UIAlertView。如果选择了我命名为“推送”的按钮,它会运行代码来推送新视图。这就是我需要从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。关于我还能做什么的任何建议?
【问题讨论】:
-
你能发布完整的警告和一些你的代码吗?
-
@rishi 查看已编辑的问题
-
我认为你必须这样做 -[self.tabBarController.selectedViewController.navigationController pushViewController:self.newView animated:YES];
标签: ios uinavigationcontroller uitabbarcontroller appdelegate pushviewcontroller