2016-12-31 7 views
0
class CustomSegue: UIStoryboardSegue { 

    override init(identifier: String?, source: UIViewController, destination: UIViewController) { 
     super.init(identifier: identifier, source: source, destination: destination) 
    } 

    override func perform() { 

     self.source.navigationController?.pushViewController(self.destination, animated: true) 

    } 

} 

上記のコードでは、segueの動作をオーバーライドしています。 種類がの場合にのみ、pushViewControllerを使用する必要があります。その他のタイプの場合はを表示(例:プッシュ)してください。UIStoryboardSegueサブクラスの識別セグの種類

サブクラスperform()では、どのようにセグのKindが見つかりますか?ストーリーボードで

 override func perform() { 

      if kind==Push { 
       self.source.navigationController?.pushViewController(self.destination, animated: true) 
      } else { 
       super.perform() 
      } 

     } 

答えて

0

すなわち

、デフォルトの動作のためのカスタムセグエなどのカスタムセグエと選択の種類などを選択セグエ、単に表示を選択セグエ(例えばプッシュ)

enter image description here

+0

しかし、コードでperform()では、カスタム動作をどのように知っていますか?そのショー(例:プッシュ) – andyPaul

+0

あなたは演技から種類を得ることができません。コードではなく、ストーリーボードで異なるセグを作成する必要があります。プッシュ・トランジションを持つカスタム・セグのような1つのセグは、デフォルト・セグでなければなりません。 – Manoj

関連する問題