3
votes

The search icon (magnifying glass) in the IOS 7 UISearchBar animates to the left with the placeholder text when the cancel button animates in but when the cancel button animates out the search icon just jumps to the center while the placeholder text animates to the center. This happens with a project from scratch whereas this doesn't happen in the search bar in the contacts app (the icon actually animates to the center with the placeholder in the app).

I tested this on the simulator. Is there something i am missing here, do i have to do something specific to get it to work the same as it does in the contacts app or is this some bug i don't know of? Using Xcode 5.0.2 .

Also i noticed there is a size (length) difference between the search bar field in IOS 6 and IOS 7, its a bit longer in 6. If anyone has some tip to get them to be the same length that would be much appreciated.

2
I managed to sort out the first issue, i will post it as an answer in another 4 hours when stackoverflow lets me.Shane

2 Answers

4
votes

I have managed to find the issue of my first question about the search icon not animating to the center.

I had called

[searchBar setShowsCancelButton:NO animated:YES];

inside of

- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar

Doing that caused the icon not to animate to the center. Instead it should be called in

- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar

I haven't found a simple solution for my other query yet though, will edit this if I figure something out for that.

0
votes

If you are using ios7 the default position of the searchbar icon is center while in the ios6 it is in left position.But If you want to make the searchbar icon at the center in ios7 you need to clear the text.For that you can add this at cancle button action. Thanks

self.searchBar.text =@"";