[英]Present while a presentation is in progress? Trying to display a new view after facebook login with parse.
I'm trying to present a UITableView I've already made for users to put in data and save in parse. 我正在尝试呈现一个UITableView,供用户放入数据并保存在解析中。 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!
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];
}
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, ie 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. [注意-modalTransitionStyle在您的原始代码中不正确,我也对此进行了更改。 Thanks to Daniel G for pointing this out]
感谢Daniel G指出这一点]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.