2010-07-30 66 views
0

我試圖在應用程序仍在運行時收到推送通知後更改視圖。我試圖在AppDelegate.miPhone - 應用程序仍在運行,接收推送通知=更改視圖

-(void)application:(UIApplication *)application didRecieveNotification:(NSDictionary *)userInfo 
{ 
    TestClass *aTestClassViewController = [[TestClass alloc]initWithNibName:@"TestClass" bundle:nil]; 
    [self presentModalViewController:aTestClassViewController animated:YES]; 
    [aTestClassViewController release]; 
} 

使用它。但是它沒有工作。我甚至無法再啓動應用程序。所以我猜這是錯誤的做法。

任何想法的傢伙?我會很感激。

回答

0

解決*** 我就是這麼做的 - > 我第一次展示的警報視圖(我需要反正) 然後使用

-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{ 
    TestClass *aSelectionScreenViewController = [[TestClass alloc] initWithNibName:@"TestClass" bundle:nil]; 
    [viewController presentModalViewController:aSelectionScreenViewController animated: YES]; 
    [aSelectionScreenViewController release]; } 
0

我們缺少的一些方面的方法你應用程序,但您的基本問題是它是接收通知的應用程序委託對象,而不是視圖控制器。這就是爲什麼你不能只做[self presentModalViewController:someViewController];

我認爲這是從你自己的答案的片段,讓你需要的東西:你的應用程序代理(大概)有一個「的viewController」成員,這是應用程序的根視圖控制器。這就是viewController對象,你需要引導它去做任何你需要的東西。在我現在看到的應用程序中,我在應用程序委託中有一個tabBarController成員,並且在通知進入時顯示警報視圖和/或更改選定選項卡索引。

我想讓您的應用程序委託在消息進入時在主視圖控制器上調用函數,並使該函數顯示警報視圖,然後執行任何狀態更改以使主視圖控制器反映接收到的通知。

相關問題