alertController没有出现在Swift中

时间:2016-11-28 00:05:18

标签: ios swift view uialertcontroller viewdidappear

我在viewDidAppear中调用该方法,但是alertController永远不会出现,似乎没有理由。

func genderAlert()
    {
        let alertController = UIAlertController(title: "Quick Question:", message: "How would you describe yourself?", preferredStyle: UIAlertControllerStyle.alert)
        let okAction = UIAlertAction(title: "Party Animal", style: UIAlertActionStyle.default) {
            UIAlertAction in
            print("Party animal Pressed")
        }
        let cancelAction = UIAlertAction(title: "Study Buddy", style: UIAlertActionStyle.default) {
            UIAlertAction in
            print("Study Buddy Pressed")
        }
        alertController.addAction(okAction)
        alertController.addAction(cancelAction)
        self.present(alertController, animated: true, completion: nil)
    }

0 个答案:

没有答案
相关问题