segue情节提要条件问题 [英] segue storyboard condition issue

查看:53
本文介绍了segue情节提要条件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个被segue喜欢的控制器:

I have this two controller liked by segue:

我的问题是:

通常,当我点击选定的表格视图"单元格时,我必须遵循segue并转到其他控制器,但是如果特定条件为真,则必须显示广告警报视图,因此我不遵循segue所以不要去那些控制器.

when I tap on selected table view'cell in general I have to follow the segue and so go to other controller , but if a specific condition is true I have to show ad alert view and so I don't follow the segue and so don't go to those controller.

这样,当我点击选定的单元格时,我总是在另一个控制器上.

In this way when I tap on selected cell I go always on the other controller.

我该如何解决这个问题?

How do I solve this problem?

推荐答案

如果覆盖此函数,则segue在返回false时不会继续,这使您有机会在某些情况下显示警告,之后可以执行SegueWithIdentifier("segueidentifier",发件人:self)和您的礼物.

if you override this function segue wont continue if you return false, this gives you the oportunity to show a warning under certain conditions, after that you can performSegueWithIdentifier("segueidentifier", sender: self), and your good to go.

override func shouldPerformSegueWithIdentifier(identifier: String!, sender: AnyObject?) -> Bool {

    if identifier == "segueidentifier" {
        //show warning and perform segue with this identifier on the accept button listener.
        return false 
    }
}
    return true
}

这篇关于segue情节提要条件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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