[英]validation before unwind ViewController
有沒有辦法在展開 ViewController 之前進行驗證?
我有我的 ViewController1 並且有一個展開功能
@IBAction func unwind(segue: UIStoryboardSegue) {
// make stuff with data
}
ViewController2 中的一個按鈕與該展開功能override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
我將數據從我的 ViewController2 傳遞到 ViewController1 中的override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
一切正常,但我想做一些驗證。
if sender as? UIBarButtonItem == self.saveButton {
if let content = self.textFieldContent.text {
publish.content = content
publish.image = self.image
} else {
self.alertMessage("Content is empty")
}
}
self.alertMessage()
函數出現,但 ViewController2 每次都被解除。 我不希望這種情況發生,我怎樣才能做到這一點?
如果您需要防止在某些情況下展開,請改用 - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender 方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.