[英]iOS 7 + iPad: UISearchBar causes navigation bar content to be mixed with status bar
UISearchBar
in a UIViewController
with a UINavigationController
UISearchBar
放在带有UINavigationController
的UIViewController
self.navigationController.navigationBar.barTintColor = [UIColor clearColor];
self.navigationController.navigationBar.barTintColor = [UIColor clearColor];
Before tap: 点按之前:
After tapping the search bar: 点击搜索栏后:
The problem happens with any color, but using [UIColor clearColor]
as in the photos attached makes it easier to see the issue. 任何颜色都会出现问题,但在附带的照片中使用
[UIColor clearColor]
可以更容易地看到问题。
Any solutions will be great, although I prefer something more elegant than hiding the navigation bar title and buttons each time. 任何解决方案都会很棒,虽然我更喜欢比每次隐藏导航栏标题和按钮更优雅的东西。
This bug happens only when using the following code in viewdidLoad
: 只有在
viewdidLoad
使用以下代码时才会发生此错误:
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
I think I got once the same issue. 我想我曾经遇到过同样的问题。 If you are using storyboards, check please that all the outlets are set:
如果您使用的是故事板,请检查所有插座是否已设置:
That fixed the animation... 修复动画...
A workaround I used eventually: 我最终使用的解决方法:
- (BOOL)prefersStatusBarHidden
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
return self.searchDisplayController.isActive;
return NO;
}
This way when user searches it hides the status bar. 这种方式,当用户搜索它时隐藏状态栏。
有完全相同的问题,修复结果是一行:
self.searchDisplayController.searchBar.translucent = NO;
I had the same problem. 我有同样的问题。 The following code worked:
以下代码有效:
self.edgesForExtendedLayout = UIRectEdgeTop;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.