我的問題是,我如何獲得以下自定義展開segue以使用iOS 9以前版本的設備以及運行iOS 9的設備?自定義解除問題iOS 8和iOS 9
我有一個自定義塞格顯示視圖控制器,然後有一個相應的自定義解繞Segue。此代碼在iOS 8中運行良好,並通過創建UIStoryboardSegue的子類和實現perform
方法來實現。然後,我重寫我的自定義導航控制器的以下方法:
- (UIStoryboardSegue *) segueForUnwindingToViewController: (UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier
{
UIStoryboardSegue *segue;
if([fromViewController isKindOfClass:[MyViewController class]]){
segue = [[CustomSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController]; //Custom Unwind Segue
}
else{
UIStoryboardSegue *unwindSegue = [super segueForUnwindingToViewController:toViewController fromViewController:fromViewController identifier:identifier]; //Normal Unwind Segue
segue = unwindSegue;
}
return segue;
}
在iOS系統中9,segueForUnwindingToViewController
已被棄用。它仍然適用於MyViewController CustomSegue;然而,默認的展開順序不再適用於任何其他展開順序。雖然在超級方法上調用方法會返回一個展開順序,但從不會發生延遲,視圖控制器永遠不會彈出,並且用戶永遠不能返回到前一個屏幕。因此,爲了清楚起見,如果我使用常規show segue,則相應的unwind segue將調用不贊成使用的方法,該方法會在super上調用該方法,但不起作用。
我觀看了WWDC在故事板上的演講,並且我能夠在iOS 9中解決這個問題:a)不再在我的自定義導航控制器中重寫此方法,並且b)進入故事板,單擊自定義細節,並輸入CustomSegue
作爲塞格級。不幸的是,由於我的目標是iOS 7,所以我收到了警告「僅在iOS 9之前自定義segues支持類名稱」,而自定義unwind segue現在不適用於iOS 7或iOS 8!