Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After updating to iOS 7 all views in iOS 6 moved up and are hidden by the navigation bar

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.

like image 452
MainstreamDeveloper00 Avatar asked Sep 19 '13 12:09

MainstreamDeveloper00


6 Answers

Try using:

navigationController.navigationBar.translucent = NO;
like image 161
sinfere Avatar answered Nov 16 '22 11:11

sinfere


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;
}
like image 36
Fervus Avatar answered Nov 16 '22 11:11

Fervus


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);
        }
    }
}
like image 36
Rob Aikins Avatar answered Nov 16 '22 11:11

Rob Aikins


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"

like image 34
shim Avatar answered Nov 16 '22 09:11

shim


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.

like image 2
moliveira Avatar answered Nov 16 '22 11:11

moliveira


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

like image 1
Idan Avatar answered Nov 16 '22 10:11

Idan