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

查看:128
本文介绍了如何防止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天全站免登陆