简体   繁体   English

如何在基于窗口的iPhone应用程序中从应用程序委托类进行导航。 如何在应用程序委托类中编写pushViewcontroller方法

[英]How to navigate from app delegate class in window based iPhone application. How to write pushViewcontroller method in app delegate class

  • In my window base application I need to navigate to informationview from my appdelegate when i click on alert view button. 在我的窗口基础应用程序中,当我单击警报视图按钮时,需要从我的appdelegate导航到informationview。
  • alert view works with NSlog. 警报视图可用于NSlog。
  • But i need to push to the other view for this purpose i used 但是我需要为此使用另一种观点

    [self.navigationController pushViewController:info animated:YES]; [self.navigationController pushViewController:info动画:是];

but it doesn't pushes. 但它不会推动。 just nslog only prints 只是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];     

        }

}

(dont consider 'i' values it is part of my logic). (不要考虑“ i”值,这是我逻辑的一部分)。 Thanks in advance 提前致谢

Before Navigate to any viewController , set the RootController for your navigationController of appDelegate. 导航到任何viewController之前,请为appDelegate的navigationController设置RootController。 Add navigationController.View as subview of window.Then your root controller will be the first ViewController.from there you can push to any viewController. 添加navigationController.View作为window的子视图,然后您的根控制器将是第一个ViewController。从那里您可以推送到任何viewController。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从应用程序委托类打开iPhone的图片库 - How to open Image Library of iphone from app delegate class iPhone - 在应用程序委托中写入 - iPhone - Write in app delegate 如何在应用程序启动时从应用程序委托加载不同的视图控制器类(即从应用程序委托) - How to load different view controller class from app delegate at the time of application launch(i.e from app delegate) 如何从另一个类访问委托方法? - How to access delegate method from another class? 如何更改应用程序委托类? - How to change the Application Delegate class? 如何在Xcode 4.4中将屏幕从应用程序委托导航到viewController - how to navigate the screen from app delegate to viewController in xcode 4.4 如何在 iPhone App Delegate 上正确添加“handleOpenURL”方法 - How to properly add “handleOpenURL” method on iPhone App Delegate 如何在iPhone中使用应用程序委托方法 - how to use application delegate method in iphone 如何在应用程序委托 class 中从我的 controller class 访问插座? - How can I access an outlet from my controller class in the app delegate class? 如何在导航 controller 上调用另一个 class 并将其添加到应用程序委托 - How to call another class on navigation controller and add it to app delegate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM