Swift:UIAlertController从列表中选择子集

时间:2015-07-09 01:15:42

标签: ios swift uialertcontroller

我有一个按钮,会显示UIAlertController。我想向用户展示几个选项,并允许他们选择一个选项的子集。

[A  +]
[B   ]
[C  +]
[D   ]
[----]
[DONE]

我需要给出一个数组来填充选项,然后让用户选择他们的子集(在这个例子中为+符号 - >使用复选标记可能更常见)。当他们点击done时,它会让代码知道他们的选择。这是来自按钮segue的当前代码。

    @IBAction func insideButton(sender: AnyObject) {
    var refreshAlert = UIAlertController(title: "Refresh", message: "All data will be lost.", preferredStyle: UIAlertControllerStyle.Alert)

    refreshAlert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { (action: UIAlertAction!) in
        print("Handle Ok logic here")
    }))

    refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .Default, handler: { (action: UIAlertAction!) in
        print("Handle Cancel Logic here")
    }))

    presentViewController(refreshAlert, animated: true, completion: nil)
}

我该怎么做?

1 个答案:

答案 0 :(得分:0)

来自UIAlertController文档:“UIAlertController类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不得修改。”

您必须制作自己的自定义提醒并进行呈现。