我试图呈现一个我已经为用户输入数据并保存在解析中的 UITableView。我很确定我没有呈现导航视图。
当我登录时,我收到错误:
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];
}
此方法已被弃用一段时间了
presentModalViewController:animated:
你应该用这个代替
presentViewController:animated:completion:
这同样适用
dismissModalViewControllerAnimated:
现在我们用这个
dismissViewControllerAnimated:completion:
当我们不需要完成块时,我们只需将其设置为 nil 即可。
但就您而言,完成块可以解决您的问题...它确保事件的正确顺序,即在解散完成之前不会发生演示。
- (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];
}];
}
[注意 - modalTransitionStyle 在您的原始代码中不正确,我也更改了它。谢谢Daniel G指出这一点]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)