How do you keep the cancel button in the search bar enabled when the keyboard is dismissed?

前端 未结 11 1792
萌比男神i
萌比男神i 2020-12-30 01:23

\"enter \"enter

11条回答
  •  情深已故
    2020-12-30 02:17

    You can use the runtime API to access the cancel button.

    UIButton *btnCancel = [self.searchBar valueForKey:@"_cancelButton"];
    [btnCancel setEnabled:YES];
    

    As far as your question is concerned, there is no way you can enable the cancel button when the keyboard is dismissed, like there is no callback as such.

提交回复
热议问题