I have a subview for which I have overridden the preferredFocusedView. The subclass has a UIView called viewToFocus. I check if that view exists, if it does I focus that view, if not I return the preferredFocusedView of the parent.
Since I updated to tvOS 10 today I am getting the following error:
'preferredFocusedView' is deprecated: first deprecated in tvOS 10.0 - Use -preferredFocusEnvironments instead.
I cant find anywhere in the documentation that explains how preferredFocusEnvironment is to be implemented. In the documentation found Supporting Focus within Your App, it says to
Override the preferredFocusedView to specify where focus should start by default.
I tried adding the UIFocusEnvironment Protocol but I am not sure how to replace the functionality of 'preferredFocusedView' with it.
- (UIView *)preferredFocusedView {
if (self.viewToFocus) {
UIView *newView = self.viewToFocus;
self.viewToFocus = nil;
return newView;
} else {
return [super preferredFocusedView];
}
}
Thanks