我的應用程序是基於導航的。其中我有一個主要的tableView顯示單元格中的feed項目。當單擊單元格時,會創建一個detailview,其中顯示該Feed項目的詳細信息。我現在正在使用推送通知。當點擊通知中的動作按鈕時,iPhone:如何重新加載tableView並從AppDelegate推一個detailView?
(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo:
被調用。我如何實現該方法,如果通知中的操作按鈕被點擊。它應該再次解析Feed,重新加載tableview,創建最新的feed項目detailview並將其推送到導航堆棧中。我嘗試了一些代碼,但沒有奏效。這是我寫的代碼。
中的AppDelegate:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
RootViewController *controller = [[RootViewController alloc] init];
[controller newFeedItem];
}
在RootViewController的:
- (void)newFeedItem
{
spinner = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinner.frame=CGRectMake(130, 170, 50, 50);
[self.view addSubview:spinner];
[spinner startAnimating];
[self performSelector:@selector(doStuff) withObject:nil afterDelay:0.01];
}
-(void)doStuff
{
[[self stories] removeAllObjects];
[self startParsing];
[self.tableView reloadData];
// create detailview and push it in navigational stack
[spinner stopAnimating];
[spinner release];
}
,但活動的指標沒有出現和的tableView也沒有重裝。爲什麼會這樣呢?提前Thanx
好,如果我不會實例化一個新的rootViewController,我將再次解析飼料。所有解析都發生在rootViewController中。是否有可能在didReceiveRemoteNotification中寫入一些代碼來訪問我已有的rootViewController? – Piscean 2011-02-25 14:14:47
是我在程序啓動時顯示rootViewController,稍後我收到遠程通知。並且我希望在點擊通知中的操作按鈕時重新加載tableView。 – Piscean 2011-02-25 14:18:30
請查看我對如何重用控制器的回答的編輯 – Olaf 2011-02-25 14:42:53