Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISearchBar height on iOS8 when showsScopeBar=YES

I'm using UISearchBar in my app, with showsScopeBar=YES. When running under iOS8 (both in the simulator and on a device) the scope bar is hidden and the search bar's height remains at 44 instead of the expected 88. Using the new view debugger in Xcode 6 I can see that the scope bar is actually present, but remains hidden behind the text field.

The only way I've found so far is to manually set the search bar's height to 88, which of course is a terrible hack.

Am I missing some documented incompatibility, or is this a bug?

like image 530
Gereon Avatar asked Sep 08 '14 13:09

Gereon


2 Answers

I ran into this problem too. After searching on Apples developer forum I found this thread: https://devforums.apple.com/thread/235803?start=0&tstart=0

And apparently the SearchBar don't automatically does a sizeToFit when it's supposed too. So it's height stays at 44 instead of adjusting to the scope buttons. The bug is not fixed in the iOS8 GM.

I did a simple [self.searchBar sizeToFit] in my viewWillAppear: and that solved it.

like image 73
Janne Avatar answered Oct 23 '22 18:10

Janne


This issue is occurring in the iOS 8 release version as well. I added these 2 lines in my viewWillAppear: and that solved it.

- (void)adjustSearchBarToShowScopeBar{ [self.searchBar sizeToFit]; self.tableView.tableHeaderView = self.searchBar; } Just adding [self.searchBar sizeToFit] was covering up my tableview's first row. Just refreshing the tableview header fixed the issue perfectly.

like image 31
megha Avatar answered Oct 23 '22 16:10

megha