I have encountered the weirdest display bug with my UISearchBar
.
Here is my code that works perfectly in another app. (I create the search bar in code because a xib file is not feasible.)
searchBar = [[UISearchBar alloc] initWithFrame:
CGRectMake(0, 0, self.tableView.frame.size.width, 44)];
searchBar.delegate = self;
searchController = [[UISearchDisplayController alloc]
initWithSearchBar:searchBar contentsController:self];
searchController.delegate = self;
searchController.searchResultsDataSource = self;
searchController.searchResultsDelegate = self;
self.tableView.tableHeaderView = searchBar;
The search functionality etc. works fine. But strangely, the search bar looks like this, both on the device and the simulator:
- The placeholder string should not be there, but further to the right.
- When I enter search text it also starts too far left, with the magnifying glass icon showing through.
- Also, setting
searchBar.placeholder
orsearchBar.prompt
to@""
ornil
does not remove this "Search" placeholder. (However, asearchBar.placeholder = @"FooBar";
will display "FooBar", but still in the wrong position. - Finally, I find it strange that the string is "Search" although I have set the language to something else (say, German).
Any help? The most pressing problem is to get the text to over the right.