好吧,我需要帮助。 我显然错过了非常明显的东西。

我读了将近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];
}

  ask by DBoyer translate from so

本文未有回复,本站智能推荐: