ios - How to set the UIView become firs tResponder? -
i learning uiresponder
now. wrote test code. in code want let uiview
become first responder, failed. test steps are:
- create
uiview
in storyboard. created class extends
uiview
view, , override methodscanbecomefirstresponder:
,becomefirstresponder
returnyes
.in method of view controller's
viewdidappear:
method, test it:- (void) viewdidappear:(bool)animated { [self.viewd becomefirstresponder]; nslog(@"%d ", [self.viewd isfirstresponder]); }
the result of isfirstresponder
no
.
i have no idea why. can me? thanks.
becomefirstresponder notifies receiver become first responder in window. yes if receiver accepts first-responder status or no if refuses status. default implementation returns yes, accepting first responder status.
a responder object becomes first responder if current responder can resign first-responder status (canresignfirstresponder) , new responder can become first responder.
in case view refuses status that's why no every time.
Comments
Post a Comment