gpt4 book ai didi

swift - accessibilityPerformEscape 不会关闭 UIAlertController

转载 作者:可可西里 更新时间:2023-11-01 02:17:04 26 4
gpt4 key购买 nike

我正在尝试显示 UIAlertContoller 并在 VoiceOver 用户执行滑动手势时关闭它:

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 并且当我执行滑动手势时它不会对其使用react,但是当警报未显示或解除时退出手势有效。

最佳答案

您需要在 accessibilityPerformEscape() 中添加关闭 UIAlertController 的代码,返回 true 是不够的。

关于swift - accessibilityPerformEscape 不会关闭 UIAlertController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36832733/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com