简体   繁体   English

performSegueWithIdentifier在iOS 9.x中导致NSInternalInconsistencyException异常,但在8.x中不会。

[英]performSegueWithIdentifier causes NSInternalInconsistencyException in iOS 9.x but not in 8.x

I have a simple button that is connected to an IBAction 我有一个连接到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. 同样,在情节提要上,我已经定义了一个segue并将其与上述标识符关联。

Everything works well in 8.x devices. 一切都在8.x设备中运行良好。

But running it on 9.x devices, I get: 但是在9.x设备上运行它,我得到:

'NSInternalInconsistencyException', reason: 'Could not perform segue with identifier 'forgotPasswordSegue'. “ NSInternalInconsistencyException”,原因:“无法执行标识符为“ forgotPasswordSegue”的segue。 A segue must either have a performHandler or it must override -perform.' 序列必须具有performHandler或必须覆盖-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. 1.您可以在情节提要或代码中选择时,将情节提要Segue定义为一种自定义类型。 modify this segue's attribute(name:kind) to Show(egPush) if you want to resolved it. 如果您想解决该问题,请将此segue的属性(名称:种类)修改为Show(例如Push)。

2.if you created a subClass of UIStoryboardSegue, follows: 2.如果您创建了UIStoryboardSegue的子类,请遵循以下步骤:

a.Override the initWithIdentifier:source:destination: method and use it to initialize your custom segue object. 重写initWithIdentifier:source:destination:方法,并使用它来初始化您的自定义segue对象。 Always call super first. 始终先呼叫超级。

b.Implement the perform method and use it to configure your transition animations. b。实施perform方法并使用它来配置过渡动画。

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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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