After updating to iOS 7 all views in iOS 6 moved u

2019-04-06 01:42发布

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.

6条回答
仙女界的扛把子
2楼-- · 2019-04-06 02:33

Try using:

navigationController.navigationBar.translucent = NO;
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-04-06 02:33

Add this value to your app plist: "View controller-based status bar appearance" and set it to "NO".

查看更多
戒情不戒烟
4楼-- · 2019-04-06 02:35

If you are using Interface Builder, I've had some luck with unchecking the setting for "extend edges" > "under top bars":

enter image description here

Works for me in iOS 7 and 6.

查看更多
Luminary・发光体
5楼-- · 2019-04-06 02:37

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.

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);
        }
    }
}
查看更多
forever°为你锁心
6楼-- · 2019-04-06 02:37

Try this:

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
    self.edgesForExtendedLayout = UIRectEdgeNone;
}
查看更多
爷的心禁止访问
7楼-- · 2019-04-06 02:48

If you're using Storyboards in Interface Builder with Autolayout, you can add a constraint for the top of your view with the "Top Layout Guide"

查看更多
登录 后发表回答