UISearchBar animation hide button

I currently have a UISearchBar (attached to a UISearchDisplayController), but I have reduced the width of the search bar so that I can display a custom button to the right of it when the search bar is not selected. The button is used to access other views.

However, when I select the search bar and then squeeze (or even do a search) and return to the normal view, where the search bar should be displayed using my custom button, the search bar enlivens and processes the entire room for the button and does not appear. In fact, the search bar takes up the entire width of the screen when I only want it to occupy part of it.

Is there a way to prevent the animation from showing full screen width?

This is how I defined the CGRect search string:

self = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 250.0f, 45.0f)] 
+6
iphone animation uisearchbar uisearchdisplaycontroller
source share
2 answers

In the end, the answer to this question was simpler than I thought. For some reason, the iPhone SDK fills the frame width in the search bar, so I have to constantly reset its size, which I want every time the user clicks the cancel button, and the searchBarCancelButtonClicked () event fires. A simple [searchBar setFrame: frame] solved this. :)

Peter, the problem with you was a bit different, I was already able to resize the search bar to what I wanted, what I needed to stop it, returning to full width. Thanks for the link though.

+3
source share

This SO post may help. It looks like you need to subclass the UISearchBar to stop its normal drawing.

UPDATE I wanted to use the UISearchBar in the UINavigationBar and resize it to fill the panel when touched - just like the behavior in a Safari application. The only way to do this is to use the UISearchBar directly. Your problem is a little different, but you can try to get the user interface behavior you want using only the search bar to get started; then plug in the search logic after that; those. not rely on UISearchDisplayController?

+1
source share

All Articles