Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISearchBar AutoLayout ios7 bug?

I'm using AutoLayout and have a UISearchBar, UITableView ad a UIView. Initially the layout is correct and positioned according to my AutoLayout rules.

enter image description here

When the UISearchBar has focus it expands abruptly in height covering my top UIView.

enter image description here

No matter how I layout my autolayout constraints this happens.

If I don't set

self.searchBar.translatesAutoresizingMaskIntoConstraints = NO;

and set a frame instead then it behaves as normal.

self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 100.0f, 45.0f)];

But i'm reliant upon AutoLayout in this app for iOS7. Is this a genuine bug? Or most probably i've missed something!

like image 853
JMWhittaker Avatar asked Oct 03 '13 05:10

JMWhittaker


1 Answers

Had the same problem. Try this in viewDidLoad

if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
    self.edgesForExtendedLayout = UIRectEdgeNone;
}
like image 117
Ben Lime Avatar answered Oct 21 '22 09:10

Ben Lime