在演示文稿正在进行时出席?尝试在Facebook登录后使用解析显示新视图。 [英] Present while a presentation is in progress? Trying to display a new view after facebook login with parse.

查看:90
本文介绍了在演示文稿正在进行时出席?尝试在Facebook登录后使用解析显示新视图。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试提供一个UITableView,我已经为用户提供了数据并保存在解析中。我很确定我没有提供导航视图。

I'm trying to present a UITableView I've already made for users to put in data and save in parse. I'm pretty sure I don't present the navigation view.

当我登录时,我收到错误:

When I log in, I get the error:

Checklists[4516:c07] Warning: Attempt to present <ChecklistsViewController: 0x10525e90> 
on <UINavigationController: 0x9648270> while a presentation is in progress!

感谢您的帮助。

#import "LoginViewController.h"
#import "ChecklistsViewController.h"
#import "SetupViewController.h"
#import <Parse/Parse.h>

@interface LoginViewController ()

@end

@implementation LoginViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    PFLogInViewController *login = [[PFLogInViewController alloc] init];
    login.fields = PFLogInFieldsFacebook;
    // Need to set the delegate to be this controller.
    login.delegate = self;
    login.signUpController.delegate = self; //signUpController is a property on the login view controller
    [self presentModalViewController:login animated:NO];

}

    - (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user
{
    [self dismissModalViewControllerAnimated:YES];
    NSLog(@"Successfully logged in.");
    ChecklistsViewController *controller = [[ChecklistsViewController alloc] initWithStyle:UITableViewStylePlain];
    controller.modalTransitionStyle = UITableViewStylePlain;
    [self presentModalViewController:controller animated:YES];

}


推荐答案

此方法已被弃用了一段时间

This method has been deprecated for a good while

     presentModalViewController:animated:

你应该使用它

    presentViewController:animated:completion:

同样适用于此

    dismissModalViewControllerAnimated:

现在我们使用这个

    dismissViewControllerAnimated:completion:

当我们不想要一个完成块,我们只需将它设置为nil。

When we don't want a completion block, we just set it to nil.

但在你的情况下,一个完成块可以解决你的问题...它确保了一个正确的序列事件,即在解雇完成之前不会进行呈现。

But in your case, a completion block could fix your problem... it ensures a correct sequence of events, i.e. the presenting won't take place until the dismissing is complete.

    - (void)logInViewController:(PFLogInViewController *)logInController 
                   didLogInUser:(PFUser *)user
{
    [self dismissViewControllerAnimated:YES completion:^{
        NSLog(@"Successfully logged in.");
        ChecklistsViewController *controller = 
              [[ChecklistsViewController alloc] initWithStyle:UITableViewStylePlain];
        controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        [self presentViewController:controller animated:YES completion:nil];
    }];

}

[NB - modalTransitionStyle在原始代码中不正确,我也改变了。感谢 Daniel G 指出这一点]

[NB - modalTransitionStyle was incorrect in your original code, I have changed that also. Thanks to Daniel G for pointing this out]

这篇关于在演示文稿正在进行时出席?尝试在Facebook登录后使用解析显示新视图。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆