更新到iOS 7后,iOS 6中的所有视图都向上移动,并被导航栏隐藏 [英] After updating to iOS 7 all views in iOS 6 moved up and are hidden by the navigation bar

查看:225
本文介绍了更新到iOS 7后,iOS 6中的所有视图都向上移动,并被导航栏隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经更新了我的iPhone到iOS 7今天重新编译我的应用程序,并且.xib文件和设备上的所有视图上移,其上部分被导航栏隐藏。在我的 viewController 我设置 self.edgesForExtendedLayout = UIRectEdgeNone; 和在iOS 7现在一切看起来不错,项目与部署目标6.0和测试它在iOS 6设备上的所有视图都被导航栏再次隐藏。如何让他们一致地看着iOS 7和iOS 6同时?我现在不想打破iOS 6的支持。

I have updated my iPhone to iOS 7 today and recompile my app for it and all views in .xib files and on device are moved up and their upper part is hidden by the navigation bar. In my viewController I set self.edgesForExtendedLayout = UIRectEdgeNone; and on iOS 7 now everything looks good but when I compile my project with Deployment Target 6.0 and tested it on iOS 6 device all views are hidden by the navigation bar again.How can I make them to look consistently on iOS 7 and iOS 6 simultaneously? I don't want to break iOS 6 support now.

推荐答案

这是我做的。这不是最干净的代码,你需要确保你不会得到奇怪的结果与您的滚动视图。

So here is what I did. It's not the cleanest code ever and you need to make sure you don't get weird results with your scroll views.

基本上,我将所有子视图向下移动导航栏的高度(45)。对于我的scrollview / tableview,在我的应用程序总是到屏幕的底部,我减少了45的高度,以便你仍然可以达到结束。这是一些解决方案,对于一些应用程序,但你应该确保所有的滚动和tableview旨在缩小像这样。

Basically I move down all of the subviews by the height of the navbar (45). For my scrollviews/tableviews, which in my app always go to the bottom of the screen, I reduce their height by 45 so that you can still reach the end. This is a solution for some apps, but you should make sure that all of your scroll and tableviews are intended to be shrunk like this.

因为它不是递归的,你不需要担心在滚动视图中的表格或类似的东西。

Because it's not recursive, you don't need to worry about tableviews in scrollviews or anything like that.

- (void)viewDidLoad
{
    [super viewDidLoad];

    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {

        self.edgesForExtendedLayout = UIRectEdgeNone;

    } else {
        [self moveAllSubviewsDown];
    }

}

- (void) moveAllSubviewsDown{
    float barHeight = 45.0;
    for (UIView *view in self.view.subviews) {

        if ([view isKindOfClass:[UIScrollView class]]) {
            view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y + barHeight, view.frame.size.width, view.frame.size.height - barHeight);
        } else {
            view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y + barHeight, view.frame.size.width, view.frame.size.height);
        }
    }
}

这篇关于更新到iOS 7后,iOS 6中的所有视图都向上移动,并被导航栏隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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