我正在使用Parse的LoginViewController,并且在登录或注册成功后,它会关闭登录屏幕,只是立即将其恢复,而不是继续使用下一个ViewController。我很肯定登录成功通过。
DefaultSettingsViewController.m:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (void)viewWillAppear:(BOOL)animated {
[super viewDidLoad];
if ([PFUser currentUser]) {
//[welcomeLabel setText:[NSString stringWithFormat:@"Welcome Back %@!", [[PFUser currentUser] username]]];
NSLog(@"PFUser is not current user");
} else {
NSLog(@"PFUser is current user");
//[welcomeLabel setText:@"Not logged in"];
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
PFLogInViewController *login = [[PFLogInViewController alloc] init];
login.fields = PFLogInFieldsUsernameAndPassword | PFLogInFieldsLogInButton | PFLogInFieldsTwitter | PFLogInFieldsFacebook | PFLogInFieldsSignUpButton | PFLogInFieldsPasswordForgotten;
login.delegate = self;
login.signUpController.delegate = self;
[self presentModalViewController:login animated:YES];
if (![PFUser currentUser]) { // No user logged in
// Create the log in view controller
PFLogInViewController *logInViewController = [[PFLogInViewController alloc] init];
[logInViewController setDelegate:self]; // Set ourselves as the delegate
// Create the sign up view controller
PFSignUpViewController *signUpViewController = [[PFSignUpViewController alloc] init];
[signUpViewController setDelegate:self]; // Set ourselves as the delegate
// Assign our sign up controller to be displayed from the login controller
[logInViewController setSignUpController:signUpViewController];
// Present the log in view controller
[self presentViewController:logInViewController animated:YES completion:NULL];
} else {
[self performSegueWithIdentifier:@"login" sender:self];
}
}
答案 0 :(得分:0)
为什么要创建两个PFLogInViewController实例(第一个“登录”,您将其作为模态视图提供,然后,如果用户未登录,则创建另一个(logInViewController),您将其转换为?
您似乎一直在使用Parse登录教程,但它们不像您那样创建它两次...
您还需要实施
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser: