3 回答

TA貢獻1830條經驗 獲得超9個贊
如果情節提要存在于情節提要中,并且在兩個視圖之間都有一個情節標識符,則可以使用以下方式以編程方式調用它:
performSegue(withIdentifier: "mySegueID", sender: nil)
對于舊版本:
performSegueWithIdentifier("mySegueID", sender: nil)
您也可以這樣做:
presentViewController(nextViewController, animated: true, completion: nil)
或者,如果您在導航控制器中:
self.navigationController?.pushViewController(nextViewController, animated: true)

TA貢獻1804條經驗 獲得超7個贊
您可以使用NSNotification
在您的自定義類中添加一個post方法:
NSNotificationCenter.defaultCenter().postNotificationName("NotificationIdentifier", object: nil)
在您的ViewController中添加觀察者:
NSNotificationCenter.defaultCenter().addObserver(self, selector: "methodOFReceivedNotication:", name:"NotificationIdentifier", object: nil)
在您的ViewController中添加功能:
func methodOFReceivedNotication(notification: NSNotification){
self.performSegueWithIdentifier("yourIdentifierInStoryboard", sender: self)
}

TA貢獻1735條經驗 獲得超5個贊
如果情節提要存在于情節提要中,并且在兩個視圖之間都有一個情節標識符,則可以使用以下方式以編程方式調用它:
self.performSegueWithIdentifier("yourIdentifierInStoryboard", sender: self)
如果您在導航控制器中
let viewController = YourViewController(nibName: "YourViewController", bundle: nil)
self.navigationController?.pushViewController(viewController, animated: true)
我將建議您使用導航控制器的第二種方法。
- 3 回答
- 0 關注
- 432 瀏覽
添加回答
舉報