Post

Replies

Boosts

Views

Activity

Reply to TVOS focus stops working in search keyboard
Some additional information: The search view controller is embedded into a UIView as follows //UIView initializer -(instancetype)init { if (self = [super initWithFrame: CGRectZero]) { //results view placeholder controller which will show search results resultsViewController = [[UIViewController alloc] init]; //seach view controller search = [[UISearchController alloc] initWithSearchResultsController: resultsViewController]; search.hidesNavigationBarDuringPresentation = NO; search.searchResultsUpdater = nil; //temporary disabled - just to minimize number //of dependencies when debugging focus issues //search.searchBar.delegate = self; search.searchBar.keyboardAppearance = UIKeyboardAppearanceDark; containerController = [[UISearchContainerViewController alloc] initWithSearchController:search]; containerController.view.autoresizesSubviews = YES; [self addSubview: containerController.view]; return self; } return nil; } //attach UISearchContainerViewController parent UIController - (UIViewController *)viewControllerForUIView:(UIView*)view { id responder = [self nextResponder]; while (responder) { if ([responder isKindOfClass:[UIViewController class]]) { return responder; } responder = [responder nextResponder]; } return nil; } - (void)addControllerToClosestParent:(UIViewController *)controller { if (!controller.parentViewController) { UIView *parentView = (UIView *)self.superview; while (parentView) { UIViewController* vc = [self viewControllerForUIView: parentView]; if (vc) { [vc addChildViewController:controller]; [controller didMoveToParentViewController:vc]; break; } parentView = (UIView *)parentView.superview; } return; } } -(void)didMoveToSuperview { if(self.superview) { [self addControllerToClosestParent:containerController]; dispatch_async(dispatch_get_main_queue(), ^{ [self setNeedsLayout]; [self layoutIfNeeded]; }); } } And when swipe stops working the first responder read at [UIWindow: sendEvent] breakpoint is (lldb) po [(UIWindow*)$arg1 performSelector:@selector(firstResponder)]; <UISearchBarTextField: 0x1078e1a00; frame = (0 0; 1650 70); text = 'i'; opaque = NO; gestureRecognizers = <NSArray: 0x301f6c4b0>; placeholder = To search, start typing, or select one of your previous searches; borderStyle = RoundedRect; background = <_UITextFieldTVBackgroundProvider: 0x3013be5b0: backgroundView=(null), textfield=<NSKVONotifying_UISearchBarTextField: 0x1078e1a00>>; layer = <CALayer: 0x301690fe0>>
Aug ’24