从AppDelegate推送视图的问题

时间:2014-12-23 20:20:12

标签: ios objective-c uinavigationcontroller storyboard uitabbarcontroller

我的应用程序包含一个UITabbarController作为根视图控制器。索引0处的视图也嵌入在UINavigatiionController中,但是我在将我的详细视图控制器推送到AppDelegate的视图时遇到了问题。我在整个应用程序中使用URL方案,允许用户在Facebook或Twitter上分享他们的帖子。下面您将看到我的应用程序何时收到URL方案通知的代码:

if ([[url scheme] isEqualToString:@"app"]) {

    if ([[url host] isEqualToString:@"post"]) {

        NSString *objectId = [[url path] stringByReplacingOccurrencesOfString:@"/" withString:@""];

        PFQuery *queryForObject = [PFQuery queryWithClassName:@"Post"];
        [queryForObject setCachePolicy:kPFCachePolicyCacheThenNetwork];
        [queryForObject getObjectInBackgroundWithId:objectId block:^(PFObject *post, NSError *error) {

            if (!error) {

                NSLog(@"Found object with ID, %@", post);

                UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
                [tabBarController setSelectedIndex:0];

                UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];

                self.navController = (UINavigationController *)[storyboard instantiateViewControllerWithIdentifier:@"mainNavy"];

                ECDDetailNewViewController *detailViewController = [storyboard instantiateViewControllerWithIdentifier:@"ShowDetailViewController"];
                [detailViewController setDetailItem:post];

                [self.navController pushViewController:detailViewController animated:YES];

            }
        }];

    }

所有内容都适用于tabbarController setSelected,但视图永远不会被推送。

从AppDelegate推送视图的最佳方法是什么?我在我的应用程序中使用了StoryBoards。

0 个答案:

没有答案