如何在segue放松之前执行条件检查 [英] how to perform Condition check, before segue unwind

查看:82
本文介绍了如何在segue放松之前执行条件检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VC1 segues到 VC3 ,其中有一个键盘和预定的最低编号可输入标签。用户可以在此字符串的末尾添加一个数字或删除一个数字。当按下Accept键时,string.toInt()被传递给 VC1 并且segue将通过

VC1 segues to VC3 which has a keypad and predetermined lowest number acceptable entered into a label. User can either add a number to the end of this string or delete a number. When "Accept" key is pressed, the string.toInt() is passed to VC1 and segue is unwind via

@IBAction func unwindToSegue(segue: UIStoryboardSegue, sender:UIStoryboardSegue){
    BetLabels[betSourceR].text = BetReturned
    if BetReturned == ""{} else{
        Chip[betSourceR].hidden = false}}

我需要实现所以不接受低于最小值的string.toInt()以及某种覆盖函数,该函数会在向用户发出不接受此输入的警告时停止发生展开。

I need to achieve so that no string.toInt() lower than minimum is accepted and some sort of override func that stops the unwind from happening while posting a warning to the user that this input is not acceptable.

我将如何实现这一目标?
也许放在 VC3 func prepareForsegue?或者另一种方法?

How would i achieve this when? Maybe place something in VC3 func prepareForsegue? Or another method?

或者我可以从展开中断开接受,并且如果在最小{警告用户之下,返回到VC3,则进行IBAction } else {VC1.unwindToSegue}

Or could i disconnect the "accept" from the unwind, and make a IBAction that if under minimum{ warn user, return to VC3} else {VC1.unwindToSegue}

推荐答案

要实现此目的,请连接控制器 VC3 到它自己的退出并选择展开动作。

To achieve this, connect Controller of VC3 to its own exit and select the unwind action.

给这个exit-segue一个 segue.identifier 你的退出文本

Give this exit-segue a segue.identifier "YOUR EXIT TEXT"

仍在 VC3 ,为接受按钮创建一个 IBAction

Still in VC3, create an IBAction for the "Accept" button.

@IBAction func accept(sender: AnyObject) {
    if //Condition X is true
        {performSegueWithIdentifier("YOUR EXIT TEXT", sender: self)}
    else {
        //Do this
        }

这篇关于如何在segue放松之前执行条件检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆