Note that there are some explanatory texts on larger screens.

plurals
  1. POUISearchBar display bug: text too far left, overlapping the magnifying glass icon
    text
    copied!<p>I have encountered the weirdest display bug with my <code>UISearchBar</code>.<br> Here is my code that works perfectly in another app. (I create the search bar in code because a xib file is not feasible.)</p> <pre><code>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; </code></pre> <p>The search functionality etc. works fine. But strangely, the search bar looks like this, both on the device and the simulator: </p> <p><img src="https://i.stack.imgur.com/pvgys.png" alt="UISearchBar with display bug"> </p> <ul> <li>The placeholder string should not be there, but further to the right. </li> <li>When I enter search text it also starts too far left, with the magnifying glass icon showing through. </li> <li>Also, setting <code>searchBar.placeholder</code> or <code>searchBar.prompt</code> to <code>@""</code> or <code>nil</code> does not remove this "Search" placeholder. (However, a<br> <code>searchBar.placeholder = @"FooBar";</code><br> will display "FooBar", but still in the wrong position.</li> <li>Finally, I find it strange that the string is "Search" although I have set the language to something else (say, German). </li> </ul> <p>Any help? The most pressing problem is to get the text to over the right.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload