如何防止 UINavigationBar 在 iOS 7 中覆盖视图顶部? [英] How to prevent UINavigationBar from covering top of view in iOS 7?

查看:21
本文介绍了如何防止 UINavigationBar 在 iOS 7 中覆盖视图顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到 Xcode 5 后,我所有应用视图中的导航栏都向下移动.这是一些屏幕截图,第一个在视图下拉时显示视图中的所有内容,第二个显示所有内容原封不动.搜索栏应该从导航栏开始.

After updating to Xcode 5, the navigation bars in all of my app's views have shifted down. Here are some screenshots, the first showing everything in the view as it's pulled down, and the second showing all of it untouched. The search bar should begin where the navigation bar.

有谁知道我该如何解决这个问题?

Anyone know how I can fix this?

我之前尝试过这个建议:

edit: i have tried this previously recommendation:

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
        self.edgesForExtendedLayout = UIRectEdgeNone;

但它产生了非常奇怪的结果.

But it yields very odd results.

这可能是因为我在这个视图控制器下有一个幻灯片菜单",这是由于导航栏的透明度而出现的.

This may be because I have a "slide menu" under this view controller that is appearing due to the transparency of the navigation bar.

推荐答案

导航栏的半透明属性设置为NO:

self.navigationController.navigationBar.translucent = NO;

这将修复导航栏和状态栏下方的视图.

This will fix the view from being framed underneath the navigation bar and status bar.

如果必须显示和隐藏导航栏,请使用

If you have to show and hide the navigation bar, then use

 if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;   // iOS 7 specific

在您的 viewDidLoad 方法中.

这篇关于如何防止 UINavigationBar 在 iOS 7 中覆盖视图顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆