簡體   English   中英

如何在基於窗口的iPhone應用程序中從應用程序委托類進行導航。 如何在應用程序委托類中編寫pushViewcontroller方法

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

  • 在我的窗口基礎應用程序中,當我單擊警報視圖按鈕時,需要從我的appdelegate導航到informationview。
  • 警報視圖可用於NSlog。
  • 但是我需要為此使用另一種觀點

    [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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM