Nic*_*chi 5 swift uialertcontroller uialertaction tvos tvos10
我想显示UIAlertController上的顶部UIViewController有一个UICollectionView内.集合视图需要专注于启动,所以我preferredFocusableView按如下方式覆盖变量:
override var preferredFocusedView: UIView? {
return self.collectionView
}
Run Code Online (Sandbox Code Playgroud)
使用tvOS 9一切正常:警报控制器正常打开,我可以选择其中一个UIAlertAction显示的.
在tvOS 10 Golden Master上,打开警报控制器并滚动到另一个动作后,焦点从屏幕上消失,我无法滚动到其他操作或点击Siri遥控器的菜单按钮.该应用程序仍然卡在警报控制器中,当我尝试滚动到其他操作但屏幕上没有任何操作时,我可以听到滚动声音.我必须强制退出应用程序并重新打开它.
这是应用程序的代码.我尝试设置preferredFocusableViewto alertController.preferredFocusedView或删除集合视图的焦点方法,但没有结果.
var alertController : UIAlertController?
func showAlert() {
alertController = UIAlertController(title:"Example title", message: "Example description", preferredStyle: .Alert)
let action1 = UIAlertAction(title: "Option 1", style: .Default) { (action : UIAlertAction) -> Void in
//call to another method
}
// action2, action3, action4...
let action5 = UIAlertAction(title: "Option 5", style: .Default) { (action : UIAlertAction) -> Void in
//call to another method
}
let actionDismiss = UIAlertAction(title: "Dismiss", style: .Destructive) { (action : UIAlertAction) -> Void in
self.alertController!.dismissViewControllerAnimated(true, completion: nil)
}
alertController!.addAction(action1)
alertController!.addAction(action2)
alertController!.addAction(action3)
alertController!.addAction(action4)
alertController!.addAction(action5)
alertController!.addAction(actionDismiss)
alertController!.preferredAction = action1
self.presentViewController(alertController!, animated: true, completion: nil)
}
override var preferredFocusedView: UIView? {
if self.alertController != nil {
return self.alertController!.preferredFocusedView
} else {
return self.collectionView
}
}
Run Code Online (Sandbox Code Playgroud)
苹果刚刚回复我的雷达:
\n\n\n\n\n\n
UIScrollView在附加的应用程序中,您\xe2\x80\x99 正在覆盖扩展中的功能以返回truefor\ncanBecomeFocused(),这是导致这些意外副作用的原因。当移动到第二个选项时,焦点似乎消失了UIAlertController;然而,它实际上是将焦点转移到围绕各个组件的滚动视图\nUIAlertController,因为由于上面提到的扩展,现在允许这样做。要解决此问题,请创建 的自定义子类, \n 仅在必须返回 的
\nUIScrollView实例中使用。canBecomeFocused()true
| 归档时间: |
|
| 查看次数: |
565 次 |
| 最近记录: |