becomeFirstResponder works in viewDidAppear but doesn't work in viewDidLoad

后端 未结 7 1082
傲寒
傲寒 2021-02-13 04:49

My Application has a modal view controller, including a search bar. When the view comes up, I want the search bar to be focused. I tried [self.searchBar becomeFirstRespond

7条回答
  •  鱼传尺愫
    2021-02-13 05:23

    Making text field/view first responder should be done after all UIViewController animations, which take place when view is loaded and presented. So the best place is viewDidAppear.

提交回复
热议问题