[英]validation before unwind ViewController
Is there a way to do a validation before unwind a ViewController?有没有办法在展开 ViewController 之前进行验证?
i have my ViewController1 and there is a unwind function我有我的 ViewController1 并且有一个展开功能
@IBAction func unwind(segue: UIStoryboardSegue) {
// make stuff with data
}
And a button from ViewController2 is conected with that unwind function, and i pass data from my ViewController2 to ViewController1 in override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
all works fine, but i want to do some validations. 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")
}
}
The self.alertMessage()
function appears but the ViewController2 is dismissed every time. self.alertMessage()
函数出现,但 ViewController2 每次都被解除。 And i dont want this to happens, how can i achieve that?我不希望这种情况发生,我怎样才能做到这一点?
如果您需要防止在某些情况下展开,请改用 - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender 方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.