Я хочу показать UIAlertController
поверх UIViewController
с UICollectionView
внутри. Представление коллекции необходимо сосредоточиться на старте, так что я перегрузили переменную preferredFocusableView
следующим образом:Фокус исчезает при открытии UIAlertController на tvOS 10 GM
override var preferredFocusedView: UIView? {
return self.collectionView
}
С tvOS 9 все работает нормально: предупреждение контроллер открыл должным образом, и я был в состоянии выбрать один из UIAlertAction
с отображаемыми.
На tvOS 10 Golden Master, после открытия контроллера предупреждения и прокрутки до другого действия, фокус исчезает с экрана, и я не могу прокрутить другие действия или нажать кнопку «Меню» на пульте Siri. Приложение остается застрявшим в контроллере предупреждения, и я могу слышать прокручиваемый звук, когда я пытаюсь прокручивать другие действия, но ничего не происходит на экране. Мне нужно выйти из приложения и снова открыть его.
Это код приложения. Я попытался установить preferredFocusableView
на 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
}
}
Где вы называете 'showAlert'? –
@ DanielStorm, когда пользователь удаляет пульт на кнопке внутри контроллера вида –
preferredFocusedView устарел в tvOS10 https://developer.apple.com/reference/uikit/uifocusenvironment/1616830-preferredfocusedview –