简体   繁体   中英

performSegueWithIdentifier causes NSInternalInconsistencyException in iOS 9.x but not in 8.x

I have a simple button that is connected to an IBAction

- (IBAction)goToForgotPasswordPage:(id)sender {
    // this works in 8.1 but breaks in 9.0
    [self performSegueWithIdentifier:@"forgotPasswordSegue" sender:nil];
}

also, on the storyboard, I have defined and connected a segue with the above identifier.

Everything works well in 8.x devices.

But running it on 9.x devices, I get:

'NSInternalInconsistencyException', reason: 'Could not perform segue with identifier 'forgotPasswordSegue'. A segue must either have a performHandler or it must override -perform.'

I am not sure what the remedy is.

Can you please help and elucidate? Much appreciated

Use this method below your method

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (IBAction)goToForgotPasswordPage:(id)sender {
[self performSegueWithIdentifier:@"forgotPasswordSegue" sender:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.

DestinationViewController *VC = (DestinationViewController*)[segue destinationViewController];
}

personally, about the problems.

1.You may define a storyboardSegue as a type of custom while you selected in storyboard or codes. modify this segue's attribute(name:kind) to Show(egPush) if you want to resolved it.

2.if you created a subClass of UIStoryboardSegue, follows:

a.Override the initWithIdentifier:source:destination: method and use it to initialize your custom segue object. Always call super first.

b.Implement the perform method and use it to configure your transition animations.

Note:If your implementation adds properties to configure the segue, you cannot configure these attributes in Interface Builder. Instead, configure the custom segue's additional properties in the prepareForSegue:sender: method of the source view controller that triggered the segue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM