2016-04-25 4 views
1

Ich versuche, eine UIAlertContoller zu zeigen und sie entlassen, wenn Voiceover-Benutzer eine Geste Peeling führt:accessibilityPerformEscape entlässt nicht 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() 
      } 
     ) 


    } 

Der obige Code zeigt die UIAlertController und wenn ich Gestrüpp Geste ausführen reagiert es nicht dazu, aber wenn die Warnung nicht angezeigt oder entlassen wird, funktioniert die Escape-Geste.

Antwort

0

Sie müssen den Code hinzufügen, um Ihre UIAlertController in accessibilityPerformEscape() zu entlassen, true ist nicht genug.