33

I am running same app in iOS6 and iOS7 which has NavigationBar.It runs well on iOS6, but in iOS7, all view is little bit up like it is not considering the Navigation bar at all.

I have tried changing topbar property in simulated metrics option but it doesnt work. It considers button's position from NavigationBar in iOS6, but in iOS7, it considers it from top of the screen.

What is the reason for it?

Thanks in advance.

iOS 6 Screenshot

iOS 7 Screenshot

PK86
  • 1,218
  • 2
  • 14
  • 25

6 Answers6

53

You should use below line for fix it in your view.

 self.edgesForExtendedLayout = UIRectEdgeNone;
sinh99
  • 3,909
  • 32
  • 32
  • yes its working fine for me. but my app have Tabbacontroller alos. Rest of the viewcontroller is working fine. Issue in Tabbar view controller. suppose i have 5 tab. 1. when i click on tab (List screen open) it working fine when i click on list detail open fine. up to yet its working fine 2. when i click on tab 2 (another list) open. that time when i clickon tab1 than detail screen main view frame decrease to 64px. i have tried to forcefully increase but not working .. what can i do in this case ?? – Hitarth Jan 24 '14 at 09:32
  • 2
    I think it is better to check before setting this property: `[self respondsToSelector:@selector(edgesForExtendedLayout)]` – jianpx Feb 13 '14 at 07:34
14

In "iOS 7 UI Transition Guide" for Layout and Appearance one also mentioned - in iOS7 in, view controllers use the full screen layout.

If we want the view shows the following location from the navigation bar, you can modify the UIViewController's edgesForExtendedLayout this property to achieve.

edgesForExtendedLayout is a type UIExtendedEdge attribute that specifies the direction of the edge to be extended.

Because iOS7 encourage full screen layout, its default value is natural to be UIRectEdgeAll, both extending around the edge, that is, if there is even the view navigationBar, under tabBar, then the view will extend coverage to the surrounding area.

If we make the following settings view, then the view will not be extended to those behind the bar, so label came out. View Source Print

self . edgesForExtendedLayout = UIRectEdgeNone ;
PK86
  • 1,218
  • 2
  • 14
  • 25
  • 1
    Using 'edgesForExtendedLayout' isn't doing the trick for me. I am adding it in viewDidLoad method. Any help would be appreciable. – Priyanka Aug 29 '13 at 06:46
  • I have implemented in 4-5 app, its working. Can you describe your scenario? – PK86 Aug 31 '13 at 11:06
  • I confirm it too. It works, you have to put it in each window – Code Guru Sep 03 '13 at 17:55
  • it's not uiextendedEdgeNone anymore, it's UIRectEdgeNone – Medhi Sep 12 '13 at 13:35
  • 1
    yeah, In earlier Xcode5 preview version it was UIExtendedEdgeNone but in latest one it is UIRectEdgeNone. – PK86 Sep 13 '13 at 05:39
  • check these blog http://www.mobinett.com/2013/08/19/ios7-ui-transition-porting-view-controller-layouts-ios6/ – PK86 Sep 23 '13 at 14:43
  • @Pranesh231286 yes its working fine for me. but my app have Tabbacontroller alos. Rest of the viewcontroller is working fine. Issue in Tabbar view controller. suppose i have 5 tab. 1. when i click on tab (List screen open) it working fine when i click on list detail open fine. up to yet its working fine 2. when i click on tab 2 (another list) open. that time when i clickon tab1 than detail screen main view frame decrease to 64px. i have tried to forcefully increase but not working .. what can i do in this case ?? – Hitarth Jan 24 '14 at 10:00
8

In iOS 7, view controllers use full-screen layout. it is mentioned in iOS 7 UI Transition Guide

if you want change the layout use edgesForExtendedLayout property

example:

   if([UIViewController instancesRespondToSelector:@selector(edgesForExtendedLayout)])

        self.edgesForExtendedLayout=UIRectEdgeNone;
hema
  • 199
  • 2
  • 1
    yes its working fine for me. but my app have Tabbacontroller alos. Rest of the viewcontroller is working fine. Issue in Tabbar view controller. suppose i have 5 tab. 1. when i click on tab (List screen open) it working fine when i click on list detail open fine. up to yet its working fine 2. when i click on tab 2 (another list) open. that time when i clickon tab1 than detail screen main view frame decrease to 64px. i have tried to forcefully increase but not working .. what can i do in this case ?? – Hitarth Jan 24 '14 at 10:00
5

At the time of this answer, iOS 7 was still under NDA, so it was not possible to write the actual solution. To help anyway, I've posted a helping link available only for registered developers.

==== Original Post: ====

Read the iOS 7 Transition Guide. Its section 'Updating the UI' explains how to fix your problem.

Tafkadasoh
  • 4,667
  • 4
  • 27
  • 31
  • 2
    At the time of my post iOS 7 was still under NDA, so the only possibility to help was to point to the official guide to which only registered developers have access. – Tafkadasoh Oct 04 '13 at 14:46
  • 1
    @Tafkadasoh I understand your dilemma and appreciate your effort to help irrespective of the NDA. I would (respectfully) suggest that you would have been better served if you had mentioned the NDA in your original answer and then detailed where exactly to find the answer to the question, i.e: "This is still under NDA; however, it is documented on page NNN of the iOS7 transition guide...". This way, you would have created a more directly helpful answer and not opened yourself up to down-voting. – Robert Altman Oct 08 '13 at 15:46
5

I had a similar issue myself and found that if you turn off the translucency of the navigation bar the views will drop down the same as they did in iOS6.

self.navigationController.navigationBar.translucent = NO;
djneely
  • 1,074
  • 13
  • 25
3
if([self respondsToSelector:@selector(edgesForExtendedLayout)])
    [self setEdgesForExtendedLayout:UIRectEdgeBottom];
Ritesh verma
  • 101
  • 1
  • 8