簡體   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