I have a popover with a search field at the top of it. There's nothing else in the popover that could be the first responder. When the popover appears, the search field always ends up starting out as the first responder. I don't want this to happen.
I've tried:
Selecting "Refuses First Responder" for the search field. This seems to solve the problem, but when you click on the search field, the becoming-first-responder animation doesn't happen.
In viewDidLoad
of my view controller:
[self.view.window makeFirstResponder:nil];
Doesn't do anything. Seems like the search field becomes the first responder after the view loads.
This did work, sort of:
[self.view.window performSelector:@selector(makeFirstResponder:) withObject:nil afterDelay:0];
But you can see the search field doing the resign-first-responder animation when the popover opens.
What can I do to prevent the search field from becoming first responder?
This should work (untested):
mayBecomeFirstResponder
property - (BOOL)acceptsFirstResponder { return self. mayBecomeFirstResponder; }
- (BOOL)acceptsFirstResponder { return self. mayBecomeFirstResponder; }
- (void)viewWillAppear
and set the search mayBecomeFirstResponder
to NO
- (void)viewDidAppear
and set the search mayBecomeFirstResponder
to YES
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.