打开接收推送通知的特定视图

| 我将“ 0”作为我的“ 1”,然后用已解析的RSS填充该表(存在一个“ 2”类,其中“ 1”是它的委托)。在ѭ1中,我有刷新RSSѭ5的方法,并将检索到的数据保存在静态
MutableArray
staticItems中: 在
tableView
单元格中单击一个单元格时,
detailView
被推到
navigationController
上,同时(选择单元格(行))我创建字典and10ѭ并传递给
detailView
。在该字典中,我传递了
staticItems
和the13ѭ(所选单元格的索引)中的值。这样,我可以显示新闻文本并跟踪新闻在新闻数组中的位置,以实现幻灯片上一页/下一页。 现在,我启用了推送通知,并且在收到一个推送通知后,我的应用程序又回到了前台,但是具有上次关闭应用程序时打开的视图。 我想通过重新解析(刷新)RSS并呈现最新消息(theItem [0])来在detailView中呈现最新消息。 因此,我想得到以下结果:调用
[rootController refreshData]
,然后在单元格中选择第一个项目并在
detailView
中将其打开 我一直在使用委托方法
didReceiveRemoteNotification
,但是我找不到使它起作用的方法。我尝试创建新的
rootController
,但随后将其堆叠在现有的:(。 请和我分享您的想法:)     
已邀请:
        首先,这个问题与推送通知根本无关。更多的问题是如何从应用程序委托中的任意位置访问视图控制器。 最好的(可能是唯一的)选择是手动保留对相关视图控制器实例的引用。 我假设您使用的是根目录为的is18ѭ,然后将明细视图控制器压入其中。在您的应用程序委托中保留对此导航控制器的引用。在您的应用程序委托中添加一个“ 19”。创建导航控制器时,请对其进行分配,以便应用程序委托具有引用。
MyAppDelegate *ad = ((MyAppDelegate *)[UIApplication sharedApplication].delegate);
ad.mainNavController = theNavController;
如果在应用程序委托本身中创建导航控制器,则显然只需要这样做:
self.mainNavController = theNavController;
然后,当您收到推送通知时,只需直接在导航控制器上操作即可。
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    // Do whatever you need to do in order to create an instance of your
    // detail view controller
    MyDetailViewController *vc = [MyDetailViewController magicalStuff:userInfo];

    // Add the detail view controller to the stack, but keep the root view
    // controller.
    UIViewController *root = self.mainNavController.topViewController;
    NSArray *vcs = [NSArray arrayWithObjects:root, vc, nil];
    [self.mainNavController setViewControllers:vcs animated:YES];
}
然后,导航控制器将向动画化为
MyDetailViewController
,然后返回按钮将带您到列表。     

要回复问题请先登录注册