我试图将我的SignupViewController.h发送到另一个视图控制器。我使用手动推送segue将SignupViewController连接到我的SetupProfileViewController。我也做了同样的事情来回到LoginView。
返回LoginView的解雇操作非常完美。但是,当我按下注册按钮时,女巫通常也会把我的SetupViewController带到iOS模拟器中崩溃。任何建议。
请参阅下面的代码。
@interface SignupViewController ()
@end
@implementation SignupViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (IBAction)signup:(id)sender {
NSString *username = [self.usernameField.text stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *password = [self.passwordField.text stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *email = [self.emailField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([username length] == 0 || [password length] == 0 || [email length] == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Please try again."
message:@"Make sure you enter all fields."
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
else {
PFUser *newUser = [PFUser user];
newUser.username = username;
newUser.password = password;
newUser.email = email;
[newUser signUpInBackgroundWithBlock:^(BOOL succeeded, 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 performSegueWithIdentifier:@"setup" sender:sender];
}
}];
}
}
- (IBAction)dismiss:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
@end