[英]How to navigate from app delegate class in window based iPhone application. How to write pushViewcontroller method in app delegate class
但是我需要为此使用另一种观点
[self.navigationController pushViewController:info动画:是];
但它不会推动。 只是nslog仅打印
- (void)applicationDidBecomeActive:(UIApplication *)application
{
//To count the number of launches
NSInteger i = [[NSUserDefaults standardUserDefaults] integerForKey:@"numOfCalls"];
[[NSUserDefaults standardUserDefaults] setInteger:i+1 forKey:@"numOfCalls"];
NSLog(@"the number of active calls are %d",i%3);
if(i%3==0 && i!=0)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"you might prefer MedChart+" message:@"Get it now for more options" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok",nil];
[alert show];
[alert release];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
NSLog(@"canceled");
}
else if (buttonIndex == 1)
{
NSLog(@"Pushed to the information view ");
InformationViewCotroller *info = [[InformationViewCotroller alloc]initWithNibName:@"InformationViewCotroller" bundle:nil];
[self.navigationController pushViewController:info animated:YES];
}
}
(不要考虑“ i”值,这是我逻辑的一部分)。 提前致谢
导航到任何viewController之前,请为appDelegate的navigationController设置RootController。 添加navigationController.View
作为window的子视图,然后您的根控制器将是第一个ViewController。从那里您可以推送到任何viewController。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.