我的應用程序設置了一個標籤欄控制器作爲RootViewController
,每個標籤有一個NavigationController
在其中。當執行某些操作時,我希望應用程序將ViewController
推到屏幕上。這個流程是當應用程序啓動或從後臺打開時,它會檢查存儲的NSDate並將其與當前日期進行比較。如果符合條件,則顯示UIAlertView
。如果選擇了名爲「Push」的按鈕,它將運行代碼以推送新視圖。這就是我需要它從AppDelegate
運行的原因,因爲不能保證如果應用程序在後臺使用時可能打開哪個標籤。由於每個標籤包含一個NavigationController
,我想我可以從AppDelegate中運行以下命令:從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
@ rishi看到編輯的問題 – user717452
我認爲你必須這樣做 - [self.tabBarController.selectedViewController.navigationController pushViewController:self.newView animated:YES]; – rishi