I have a segue that is being called progmatically by performSegueWithIdentifier:
but it will not trigger. However, when I create the segue with a button press the segue works without a problem. I have also tried changing the name of my segue in code, and it produces a no segue with identifier
error.
Here is my code (Note: the segue is called in two different places to check if it would work somewhere else in the code.)
#import "SignUpViewController.h"
#import "ProgressHUD.h"
@interface SignUpViewController ()
@end
@implementation SignUpViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self performSegueWithIdentifier:@"profilePic" sender:self];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (IBAction)createAnAccount:(id)sender {
[ProgressHUD show:@"Please Wait"];
if ([self.passwrod.text isEqualToString:self.confirmPassword.text]){
// Register User
PFUser *user = [PFUser user];
user.username = self.username.text;
user.password = self.passwrod.text;
user.email = self.eMail.text;
// other fields can be set if you want to save more information
NSString *name = [self.firstName.text stringByAppendingString:@" "];
NSString *fullName = [name stringByAppendingString:self.lastName.text];
user[@"name"] = fullName;
user[@"posts"] = @0;
user[@"score"] = @5;
user[@"followers"] = @0;
user[@"following"] = @0;
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
// Hooray! Let them use the app now.
[self performSegueWithIdentifier:@"profilePic" sender:self];
[ProgressHUD showSuccess:nil];
NSLog(@"Perform Segue");
} else {
NSString *errorString = [error userInfo][@"error"];
// Show the errorString somewhere and let the user try again.
[ProgressHUD showError:errorString];
}
}];
} else {
// Alert User
[ProgressHUD showError:@"Please check your passwords as they do not match."];
}
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSLog(@"Preparing for segue");
NSLog(@"Segue: %@", segue.identifier);
}
@end
Update for clarification: The prepareForSegue
method is being called and logging.
Thanks for your help!