Forced method that is not called in my custom UISearchBar class

I am adding a UISearchBar that has been initialized using a custom class in a UIView. And I redefined the touchBegan () method.

And I turned on user interaction in the UISearchBar. But touching the Began () method does not work when you click on the search bar.

Any idea why touchsBegan () is not being called? It will be great if someone can help me.

+4
source share
2 answers

you need to set a delegate for the UISearchBar. In this case, in the .h file, enter the type UIViewController. Then, in the nib file, be sure to connect your search bar to the name of your search bar found in the "Referencing Outputs" section. Hope this helps you.

+2
source

Are you sure you configured your custom class in Interface Builder as a UISearchBar?

0
source

Source: https://habr.com/ru/post/1435259/


All Articles