繁体   English   中英

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

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

我有一个连接到IBAction的简单按钮

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

同样,在情节提要上,我已经定义了一个segue并将其与上述标识符关联。

一切都在8.x设备中运行良好。

但是在9.x设备上运行它,我得到:

“ NSInternalInconsistencyException”,原因:“无法执行标识符为“ forgotPasswordSegue”的segue。 序列必须具有performHandler或必须覆盖-perform。

我不确定该怎么办。

您能帮忙说明一下吗? 非常感激

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];
}

就问题而言。

1.您可以在情节提要或代码中选择时,将情节提要Segue定义为一种自定义类型。 如果您想解决该问题,请将此segue的属性(名称:种类)修改为Show(例如Push)。

2.如果您创建了UIStoryboardSegue的子类,请遵循以下步骤:

重写initWithIdentifier:source:destination:方法,并使用它来初始化您的自定义segue对象。 始终先呼叫超级。

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