5

There is UIView, status bar, iOS 7 and iOS 6. With iOS 6 everything is good: my UIView (transparent, under "Tap to set destination" label) appears right below status bar. Here is the picture:

enter image description here

The problem is with iOS 7. Here:

enter image description here

I expect that UIView will be under status bar, not beneath it. I have already tried to detect iOS version and if it's 7 or upper change UIView frame programmatically. But my UI with all the constraints made in storyboard... So it did not help. What can I do to resolve this problem?

UPD: maybe I really should make design more capable for iOS7? I'll think about it, and thanks for recommendations!

Maria
  • 755
  • 1
  • 11
  • 29
  • please ket us know in which life cycle method you are detecting ios version and relocating frame of the UIView? – 2intor Dec 26 '13 at 14:31
  • 3
    This seems completely normal for iOS7 - maybe you need to have a read of the iOS 7 transition guide https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/ as a side note this has nothing to do with the `xcode IDE` so please don't use that tag. Try to remember this if you consider tagging your question with 'xcode', you probably shouldn't. – Popeye Dec 26 '13 at 14:34
  • in viewDidLoad (main viewController). – Maria Dec 26 '13 at 14:35
  • 2
    Why do you need this? The full screen layout you see is default behavior in iOS7, it is done intentionally. May be it's time to reconsider you design, otherwise your app may look old-fashioned in the new OS. – yurish Dec 26 '13 at 14:37
  • Popeye, I know that it's normal, but it looks terrible now, and I want to make it really nice :) – Maria Dec 26 '13 at 14:37
  • yurish, do you think the second screenshot is OK? I suppose that UIView should be a little heigher than in iOS6 version. – Maria Dec 26 '13 at 14:38
  • The second screenshot looks normal for iOS7 applications. Take a Look at apps developed by Apple to compare. Not sure I understand the phrase about UIView. – yurish Dec 26 '13 at 14:42
  • I mean that the UIView.frame.size.height should be bigger for iOS7 version of my app. Maybe. – Maria Dec 26 '13 at 14:44
  • Yes, the height of the view will be larger in iOS7. – yurish Dec 26 '13 at 14:53
  • 1
    Look at the `topLayoutGuide` property on `UIViewController`. – Jiri Dec 26 '13 at 14:59
  • have you tried this: self.edgesForExtendedLayout = UIRectEdgeNone; in the viewDidLoad method of your view controller?? – Abdullah Umer Dec 26 '13 at 16:45
  • Yes, but it does not work. Maybe because there is no navigation bar – Maria Dec 27 '13 at 02:29

4 Answers4

4

In your View Controller viewDidLoad, you should add:

if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)) {
    [self setEdgesForExtendedLayout:UIRectEdgeNone];
}
LuisEspinoza
  • 8,508
  • 6
  • 35
  • 57
2

If you really really need to do this you can place the map view inside another view that will be the root view of the controller. This root view will be under the status bar in iOS 6 and take full screen in iOS 7. Set black background for the root view.

Add constrains from this root view to the map view and in viewDidLoad: check iOS version. In iOS 7 change top constrain from 0 to the status bar height (or add contain to topLayoutGuide and remove the top constrain).

But again the behavior you see is normal for iOS 7, and trying to make you view under the status bar you make your app look old-fashioned. May be it's time to reconsider you design.

yurish
  • 1,515
  • 1
  • 15
  • 16
0

In iOS 7 that's the default behavior of status bar. I guess the easiest solution will be to hide the status bar all together.

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
        // iOS 7
        [self prefersStatusBarHidden];
        [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
    } else {
        // iOS 6
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
    }

}

// Add this Method
- (BOOL)prefersStatusBarHidden
{
    return YES;
}
Sam B
  • 27,273
  • 15
  • 84
  • 121
  • 2
    That’s not a solution. Apps should only hide the status bar when there’s a good reason to, not just out of laziness. From the HIG: “Permanently hiding the status bar means that users must switch away from your app to read the time or to find out whether they have a Wi-Fi connection.” Hiding the status bar also makes it more inconvenient to access Control Center and Notification Center. – Noah Witherspoon Dec 26 '13 at 14:35
  • Thanks a lot, but I don't want to hide the status bar. – Maria Dec 26 '13 at 14:36
  • @NoahWitherspoon in iOS 7 the status bar comes overlaid on all views. You cannot move your views up and down to make it look like "iOS 6". That's why every app that I had updated or made for iOS 7 I end up hiding it. Not because I am lazy because there is no other choice – Sam B Dec 26 '13 at 14:38
  • Yes, you can. Many apps that support both iOS 6 and 7 already do so. `[[UIDevice currentDevice] systemVersion]` is your friend here. – Noah Witherspoon Dec 26 '13 at 14:52
0

Try many ways, I saw dozens of post. Finally this is the best solution I found.

Proper way to hide status bar on iOS, with animation and resizing root view

Community
  • 1
  • 1
jose920405
  • 7,982
  • 6
  • 45
  • 71