29

How can I add top layout guide in NIB file or how can I specify space from the top navigation bar and status bar so that it does not create problem between ios 6 and iOS 7?

Unheilig
  • 16,196
  • 193
  • 68
  • 98
Vibhooti
  • 1,193
  • 2
  • 9
  • 20

3 Answers3

27

You can do this by by implementing new property called edgesForExtendedLayout in iOS7 SDK

-(void)viewDidLoad {
      if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
         self.edgesForExtendedLayout = UIRectEdgeNone;
}

or

If you are using navigation bar and xcode5 then..

In Interface Builder,select view controller, and then navigate to the attributes inspector. In "Extend Edges". check Under Top Bars

i have solved my problem from Here

Community
  • 1
  • 1
the1pawan
  • 1,194
  • 9
  • 26
  • 2
    Technically, you are accessing `setEdgesForExtendedLayout:` so you are kinda checking for response from the wrong method. But that's just nitpicking. – lxcid Sep 26 '14 at 05:24
  • 1
    This doesn't help, because I have a background that I want to be visible through a transparent navigation bar. `edgesForExtendedLayout` pushes everything down. – Jadar Sep 30 '15 at 03:06
3

I think you need to write this condition for that

 float SystemVersion=[[[UIDevice currentDevice] systemVersion] floatValue];
  if(SystemVersion<7.0f)
   {
     //Currently your app is running in IOS6 or older version. So you need not 
             to do anything.
   }
  else
   {
     // Currently your app is running in IOS7.
   } 
Parvendra Singh
  • 965
  • 7
  • 19
-2

I am doing it programmatically.
because you have to check both the frame sizes for ios 7 and others.
because for status bar you have to manage 20 pixel in IOS 7 and other.
so, just put View in XIB as you want in any IOS and for other you can manage by this...

CGSize result = [[UIScreen mainScreen] bounds].size;
        if(result.height == 480)
        {
   NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
            if ([[vComp objectAtIndex:0] intValue] >= 7) {
                NSLog(@"Ios7 resize the frame");

            }
            else
            {


            }

}

        if(result.height == 568)
        {
  NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
            if ([[vComp objectAtIndex:0] intValue] >= 7) {
                NSLog(@"Ios7 resize the frame");


            }
            else
            {


            }

Hope this helps....

Sam
  • 431
  • 7
  • 23
  • The problem with this code is that it is highly dependent on the screen size. These kind of things tend to change often! – Artem Abramov May 08 '15 at 14:46