2016-04-25 91 views
1

我试图显示UIAlertContoller并关闭它时VoiceOver的用户执行擦洗手势:accessibilityPerformEscape不会关闭UIAlertController

override func accessibilityPerformMagicTap() -> Bool { 
     showPopup() 
     return true 
    } 

    override func accessibilityPerformEscape() -> Bool { 
     print("close") 
     return true 
    } 

    func showPopup(){ 
     baseAlert = UIAlertController(title: "Popup", message: "Choose an option", preferredStyle: .Alert) 
     let firstAction = UIAlertAction(title: "method 1", style: .Default) { (alert: UIAlertAction!) -> Void in 
      print("one") 
     } 

     let secondAction = UIAlertAction(title: "method 2", style: .Default) { (alert: UIAlertAction!) -> Void in 
      print("two") 
     } 

     let thirdAction = UIAlertAction(title: "method 3", style: .Default) { (alert: UIAlertAction!) -> Void in 
      print("three") 
     } 

     let closeAction = UIAlertAction(title: "Close", style: .Destructive) { (alert: UIAlertAction!) -> Void in 
      print("close") 
      self.accessibilityPerformEscape() 
     } 

     baseAlert.addAction(firstAction) 
     baseAlert.addAction(secondAction) 
     baseAlert.addAction(thirdAction) 
      baseAlert.addAction(closeAction) 

     baseAlert.accessibilityHint = "Pop menu" 
     presentViewController(baseAlert, animated: true, completion: 
      { 
        self.textField.becomeFirstResponder() 
      } 
     ) 


    } 

上面的代码示出了UIAlertController并且当我执行擦洗手势它不反应它,但是当警报没有显示或解散逃生手势作品。

回答

0

您需要添加代码以解除您的UIAlertController的accessibilityPerformEscape(),返回true是不够的。