iOS 6/7 20px difference using autolayout - ios

I've got a background for the project that I am working on, which includes a 20px coloured bar for the top of an iOS 7 device.
This worked fine without autolayout, setting a 20px delta in storyboard. But now I can't do that, and I am stuck with constraints - which I cannot set on a per-OS basis.
Whatever I do, I seem to end up with the version on iOS 7 being 20px higher than on ios 6... Something I need to rectify, as I also have a bar under that status bar which is coloured for a navigation controller.
I've attached the background image - if I need to modify it to work with autolayout, I'm happy to do that.

There is a "top layout guide" object in your view hierarchy. If you build vertical constraints based on that, they pin to the top of the window if there is no status bar, or under the status bar otherwise. Use that.

Related

IOS 11 navigation bar appears smaller than it should

I have a custom navigation bar that worked well until iOS 11. It appears smaller than it should and seems to ignore the status bar height or something.
I set the whole thing programmatically and the height is set to 64.
have you tried to disable (untick) safe area?

Status bar overlaps on my view

I have a UIViewController subclass which when I run the app on iOS 7, the status bar shows on top of my view. Is there a way to avoid this? I do not want the status bar to be hidden. Is there a way to show the status bar above my app. I present my view using presentViewController. Please guide what I am missing?
In Xcode, In storyboard there is an option of iOS6/7 delta. set delta Y to 20 pixel of your view, to make compatible with iOS7.For this you have to disable auto layout, you can use auto resizing.
This is quite common issue. Starting from iOS 7 Status Bar is a part of the controller's view. Apple even have added special attribute of UIView in the Interface Builder: iOS 6/7 Deltas. To fix your problem and make your view look the same in different iOS versions, go to Size inspector and set Delta Y to 20.0.

iOS 8 Handle status bar on xib files not storyboard

I have an app that I want to upgrade to iOS 8, but since I found that status bar is being hidden on iPhone in landscape mode, I figured that I need to handle such a behaviour.
I solved this issue on iOS 7 by adding a constraint from the top of the navigation bar to the top of the view ( since I am not using Storyboards, some properties or features are not available through xib like top layout guide ) and used this method:
(UIBarPosition)positionForBar:(id<UIBarPositioning>)bar
{
return UIBarPositionTopAttached;
}
and it was working like charm, but on iOS 8 when status bar is hidden on landscape, navigation bar appears much taller that it is supposed to be. I may handle through constraints and use rotating events, but I believe there must be better ways to handle it.

iOS 6/7 Delta's not working iOS 7.1

My app is in the app store, was working fine with deltas set for ios7. With the recent 7.1 update, these deltas seem to magically have stopped working.
Anyone know more about this issue? Googling provided no relevant links. This HAS to have happened to someone else.
This problem was eating my lunch, too. In my particular case, it was an easy fix.
For me, the crux of the problem was my ignorance of the implications of a translucent navigation bars I didn't even need to use the iOS 6/7 deltas the way I was using them.
With a translucent navigation bar, the coordinate (0,0) of the parent view is the top left corner of the navigation bar. However, when the navigation bar is opaque, the parent view's coordinate (0,0) is just below the navigation bar on the far left. I was using iOS 6/7 deltas to compensate for the different navigation bar heights between the two platform versions. I was trying to use translucent navigation bars like opaque navigation bars and I didn't realize it.
My solution was to change all of my navigation bars to opaque and move the views to autolayout. This allowed my views & controls to be positioned relative to the "top" of the parent view with "top" being what I was expecting: the border of the navigation bar.
Hopefully this helps.

My app from iOS6 to iOS7 Label issue

i want to change iOS6 application to iOS7.(i.e)i want iOS7 compatibility. When i run my application in iOS7 simulator,view is moving up.
Can someone help me?
The full size of the iPhone Screen (non-retina, for simplicity sake, since that what we use with layout coordinates) is 320x480.
In iOS6 and previous, from a developer standpoint, the screen size was actually 320x460, with a 320x20 strip at the top for the status bar. In iOS6, the point x=0, y=0 translates to the iOS7 point of x=0,y=20.
This is because now the status bar is transparent an you can controller how that 320x20 strip at the top looks.
If you want to support both, you need to check which version of iOS they're using, and if they're using iOS7 or greater, you need to increment the origin.y by 20 pretty much everywhere.
Borrowed from this StackOverflow answer, here is how to programmatically determine which version of iOS is running:
NSString *version = [[UIDevice currentDevice] systemVersion];
int ver = [version intValue];
if (ver < 7) {
//iOS 6 work
} else {
//iOS 7 related work
}
Because by default viewcontroller have extended edges and it will go under top bar, set it to UIedgeRectNone then view will not go under the top bar.
self.edgesForExtendedLayout = UIRectEdgeNone;
Best way to support both iOS6 and iOS7 without much pain is to pack all your view controllers inside navigation controller (with navigation bar set to hidden if necessary).
This will allow to automatically and cleanly handle status bar behaviour changes.
People are nibbling around the correct answer, but haven't given it. I struggled with this for weeks, and finally figured out how to handle it correctly.
How to handle layout differences between iOS 6 and iOS 7 so you can support both without custom code:
The answer is different depending on whether you're using auto-layout or struts and springs.
For auto layout, you tie your top constraints to the "top layout guide", an imaginary line that starts at the content area of the window. It's under any status bar or navigation bar that's present, and moves up if either or both of those items are not shown.
For struts and strings based layout, IB has a mechanism that will let you adjust your view layout automatically.
Select your nib file/storyboard file.
Open the "File inspector" on the right side and look for an item titled "View as". Set that to "iOS 6.1 and earlier. This does several things. It makes your UI look like the app is running under iOS 6, and it makes the geometry work as if it's running under iOS 6.1 rules (the 0.0 point of your content view is under the status bar and your effective screen size is 20 points smaller when the status bar is shown.)
Next, select the views that are pinned to the top of your screen and choose the Size Inspector. (The tab in the utilities area that looks like a ruler). There is a new section of the size inspector called "iOS 6/7 deltas." This lets you specify changes to apply to the selected view when running in the "other" version of iOS than the one you specified above in the file inspector. Since we specified iOS 6, the current layout is using iOS 6 rules, so we want to specify the changes that are needed when running iOS 7 instead. If we had specified "View as iOS 7" in the file inspector, we'd be seeing an iOS 7 layout, and we'd be specifying changes to make when we run under iOS 6. You can do it either way. However, beware. If you have delta values (described below) and then switch this setting, IB moves stuff around on you in very confusing and destructive ways. Don't do that. Pick a value for the "View as" setting and stick with it for your entire app or you will get very confused and frustrated.
You want to make your navigation bars 20 points taller (They then automatically tint the status bar and adjust their layout so their titles and bar button items don't overlap the status bar.)
You also typically want to make views that are pinned to the top of the screen have a delta Y of 20 points to shift them down to make room for the status bar.
If a view is also pinned to the bottom of the screen so it's size adapts with the screen size, you'll probably also want a delta height of -20 pixels.
It takes some tinkering to get everything working right, but by setting your "iOS 6/7 delta" values correctly, you can create IB files that work correctly on both OS versions without any custom code.
If you DO have custom code to do things like tweak your layout for user interface orientation, though, things get really confusing.

Resources