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

发布于 2025-01-08 04:13:13 字数 1417 浏览 3 评论 0原文

  • 在我的窗口基础应用程序中,当我单击警报视图按钮时,我需要从我的应用程序代理导航到信息视图。
  • 警报视图与 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吃素的狼 2025-01-15 04:13:13

在导航到任何 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文