我的应用程序是基于导航的。其中我有一个主要的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