我的登录和注册按钮工作但由于某些原因我填写了unsername和密码字段 - 并按下登录按钮 - 按钮不会推送到我的收件箱控制器。但是,如果我停止我的项目,然后重新运行它,它将加载登录。我不知道为什么!任何帮助将不胜感激 -
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.navigationItem.hidesBackButton = YES;
}
- (IBAction)login:(id)sender {
NSString *username = [self.usernameField.text
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *password = [self.passwordField.text
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([username length] == 0 || [password length] == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops!"
message:@"Make sure you enter a username and password!"
delegate:Nil cancelButtonTitle:@"Okey"
otherButtonTitles:nil];
[alertView show];
} else {
[PFUser logInWithUsernameInBackground:username password:password block:^(PFUser *user, NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry!"
message:[error.userInfo objectForKey:@"error"]
delegate:Nil cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
} else {
[self.navigationController popToRootViewControllerAnimated:YES];
}
}];
}
}
@end