我目前正在编写一个应用程序,该应用程序具有以 Parse 作为后端的登录和注册页面。我能够获得用户名和所有注册的用户名,但是如果其中一个字段为空白,我需要有关通知用户的代码的帮助。我想显示错误的 UIAlertView 并防止在这种情况下切换视图(它切换然后显示字段留空的通知)。我知道这可能很简单。只需要一点帮助。这是下面的代码。
-(IBAction)signUpUserPressed:(id)sender
{
PFUser *user = [PFUser user];
user.username = self.userRegisterTextField.text;
user.password = self.passwordRegisterTextField.text;
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
[self performSegueWithIdentifier:@"FinishSignup" sender:self];
} else {
[[[UIAlertView alloc] initWithTitle:@"Error" message:[error userInfo][@"error"] delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil] show];
}
}];
}
帮助将不胜感激。这也类似于您正在注销应用程序并询问您是否要注销 - 停止视图切换和显示通知。
谢谢!