如何从基于窗口的 iPhone 应用程序中的应用程序委托类进行导航。如何在应用程序委托类中编写pushViewcontroller方法
- 在我的窗口基础应用程序中,当我单击警报视图按钮时,我需要从我的应用程序代理导航到信息视图。
- 警报视图与 NSlog 一起使用。
但是我需要推送到另一个视图来实现我使用的目的
[self.navigationController PushViewController:信息动画:是];
但它不推动。只是 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”值,它是我逻辑的一部分)。 提前致谢
- In my window base application I need to navigate to informationview from my appdelegate when i click on alert view button.
- alert view works with NSlog.
But i need to push to the other view for this purpose i used
[self.navigationController pushViewController:info animated:YES];
but it doesn't pushes. just nslog only prints
- (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];
}
}
(dont consider 'i' values it is part of my logic).
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在导航到任何 viewController 之前,请为 appDelegate 的 navigationController 设置 RootController。
添加
navigationController.View
作为窗口的子视图。然后你的根控制器将是第一个 ViewController。从那里你可以推送到任何 viewController。Before Navigate to any viewController , set the RootController for your navigationController of appDelegate.
Add
navigationController.View
as subview of window.Then your root controller will be the first ViewController.from there you can push to any viewController.