xcode 在演示过程中演示?尝试使用解析在 facebook 登录后显示新视图。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14971511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:48:53  来源:igfitidea点击:

Present while a presentation is in progress? Trying to display a new view after facebook login with parse.

iosobjective-cxcode

提问by STANGMMX

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.

我正在尝试展示我已经为用户制作的 UITableView 以放入数据并保存在解析中。我很确定我没有展示导航视图。

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!

Thanks for your help.

谢谢你的帮助。

#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];

}

回答by foundry

This method has been deprecated for a good while

这个方法已经被弃用了很长时间

     presentModalViewController:animated:

You should use this instead

你应该改用这个

    presentViewController:animated:completion:

Same goes for this

同样适用于此

    dismissModalViewControllerAnimated:

Now we use this

现在我们用这个

    dismissViewControllerAnimated:completion:

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

当我们不需要完成块时,我们只需将其设置为 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 was incorrect in your original code, I have changed that also. Thanks to Daniel Gfor pointing this out]

[注意 - modalTransitionStyle 在您的原始代码中不正确,我也已更改。感谢Daniel G指出这一点]