重新创建Anypic导航流程

时间:2014-04-20 02:22:40

标签: ios objective-c uinavigationcontroller parse-platform

好的,我需要帮助。我显然遗漏了一些非常明显的东西。

我在这个确切的错误上阅读了近30篇帖子,但是这个应用程序仍在与我搞砸。我几乎复制了Anypic应用程序(Parse.com)的导航流程,因为它非常类似于我想在我的应用程序中执行的操作。首先,Anypic认为他们可以将tabBar控制器推送到一个视图控制器上,据我所知,这种控制器不起作用,因此在我的实现中我会以模态方式呈现它。

我正在使用故事板!并获得对每个视图控制器的引用,如下所示:

self.storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
CustomViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VC"];

这是错误: 尝试在NFWelcomeViewController上呈现UITabBarController,其视图不在窗口层次结构中!

请帮忙!

NFWelcomeViewController


-(void)viewDidLoad {

    [super viewDidLoad];

    // If not logged in, present login view controller
    if (![PFUser currentUser]) {
       [self performSegueWithIdentifier:@"showLogin" sender:self];
    }

    else {

        // Present Notified UI
        // [(AppDelegate*)[[UIApplication sharedApplication] delegate] presentTabBarController];
        [self performSegueWithIdentifier:@"tabBar" sender:self];

        // Refresh current user with server side data -- checks if user is still valid and so on
        [[PFUser currentUser] refreshInBackgroundWithTarget:self selector:@selector(refreshCurrentUserCallbackWithResult:error:)];
    }

}

AppDelegate(我现在注释掉了,理想情况下我想像Anypic一样实现它)

- (void)presentLoginViewControllerAnimated:(BOOL)animated {
    NSLog(@"present login");

    NFLoginViewController *loginViewController = [[NFLoginViewController alloc] init];
    [loginViewController setDelegate:self];
    loginViewController.fields = PFLogInFieldsFacebook | PFLogInFieldsUsernameAndPassword;
    loginViewController.facebookPermissions = @[ @"basic_info", @"email" ];

    [self.welcomeViewController presentViewController:loginViewController animated:YES completion:NULL];
   // [self.welcomeViewController presentViewController:loginViewController animated:YES completion:nil];
}

- (void)presentLoginViewController {
    [self presentLoginViewControllerAnimated:YES];
}

- (void)presentTabBarController {

    NSLog(@"present tabBar");

    self.tabBarController = [self.storyboard instantiateViewControllerWithIdentifier:@"tabBar"];

    [self.welcomeViewController.navigationController pushViewController:self.tabBarController animated:NO];

    [self.navController setViewControllers:@[ self.welcomeViewController, self.tabBarController ] animated:NO];

    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|
     UIRemoteNotificationTypeAlert|
     UIRemoteNotificationTypeSound];
}

0 个答案:

没有答案