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.

在这里输入图像描述

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

在这里输入图像描述

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!


Had the same problem. Try this in viewDidLoad

if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
    self.edgesForExtendedLayout = UIRectEdgeNone;
}
链接地址: http://www.djcxy.com/p/16308.html

上一篇: readRDS()加载额外的包

下一篇: UISearchBar AutoLayout ios7错误?