如何在swift中为警报视图设置标签。我无法设置标签alert.tag = 1
,如果我这样做,我会得到类似'UIAlertController' does not have a member named 'tag'
的错误。下面是我写的代码,在SWIFT中为UIAlertController设置标签?
var alert = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "YES", style: UIAlertActionStyle.Default, handler:{ (ACTION :UIAlertAction!)in }))
alert.addAction(UIAlertAction(title: "NO", style: UIAlertActionStyle.Default, handler:{ (ACTION :UIAlertAction!)in }))
alert.tag = 1 // Error is shown here
self.presentViewController(alert, animated: true, completion: nil)
我们用来为Obj-C中的警报视图设置标签。有人能帮我解决这个问题吗?提前致谢。
你应该使用'handler'模块来执行一个按钮的动作。 'tag'标志不可用于'UIAlertController'。 – holex 2014-11-04 10:33:04