1

我正在实现UIAlertControllerin tvOS 平台。它工作正常,但是当我点击按钮操作时,不会调用该操作。但是当用两个按钮上下移动并点击任何一个动作时。

这是我的代码。

func showAlertMessage() {

        let alertController = UIAlertController(title: kAlertMessage, message: "", preferredStyle: UIAlertControllerStyle.Alert)
        let cancelButton = UIAlertAction(title: kCancelButton, style: UIAlertActionStyle.Default) { (action) -> Void in

            self.dismissView()
        }
        let retryButton = UIAlertAction(title: kRetryButton, style: UIAlertActionStyle.Default) { (action) -> Void in

            if self.playerObj != nil{

                if self.controlFlag == false {

                    self.playerItem?.removeObserver(self, forKeyPath: "status")
                }else{

                    self.playerItem?.removeObserver(self, forKeyPath: "status")
                }
                self.playerObj = nil
                self.playerItem = nil
                self.asset = nil
            }
             self.parseJSON()
        }

        alertController.addAction(retryButton)
        alertController.addAction(cancelButton)
        if self.alertMessageFlag != true {
            dispatch_async(dispatch_get_main_queue()) { () -> Void in

                self.presentViewController(alertController, animated: true, completion: nil)
            }
        }
    }  

请找出问题并建议我。谢谢你。

4

0 回答 0