8
votes

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!

1
You can add height constraints to your UISearchBar view.Raj Subbiah
Yes I have tried that as an additional constraint, makes zero difference.JMWhittaker
Did you add top, leading, trailing and height constraints to your UISearchBar view?Raj Subbiah
Hello @JMWhittaker, did you solve this issue?Ranjit

1 Answers

3
votes

Had the same problem. Try this in viewDidLoad

if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
    self.edgesForExtendedLayout = UIRectEdgeNone;
}