how to set iOS 6/7 Deltas programmatically
Asked Answered
R

4

13

I was developing a UISplitView app by using Xcode 4.6 when I left iOS6 I had design:

enter image description here

Now I migrate to new Xcode5 and now I have this design:

enter image description here

UINavigationBar overlaps completelly my UISearchBar...

Leo Natan told me about using a iOS 6/7 Deltas but since I'm creating and adding my UISplitViewControllers programmatically,

this may doesn't work I need to set the iOS 6/7 programmatically but I don't know how, any help I'll appreciate

Renaldorenard answered 25/9, 2013 at 15:20 Comment(3)
If you want to do this in code, you have to work with frames. if (iOS7) {view.frame = ...} else {view.frame = ...}Tyrannicide
@PetroKorienev Or just change constraint constants? It's easier than to update frames.Pupil
The OP doesn't use auto-layout, and initialized his controllers in code. Adding constraints in code isn't way easier than updating frames..Tyrannicide
A
17

In iOS 7 there are now extended edges, and that's why navigation bar overlaping the searchbar. You can set self.edgesForExtendedLayout = UIRectEdgeNone; this is UIVewControlelr property. You can also make checks depending on version of iOS and You can do things depending on current version of iOS in device.

NSString *version = [[UIDevice currentDevice] systemVersion];
int ver = [version intValue];
if (ver < 7){
//iOS 6 work
}
else{
//iOS 7 related work
}
Anatolio answered 25/9, 2013 at 15:52 Comment(0)
I
5

Also, you can use NSFoundationVersionNumber

if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
  // > iOS7
} else {
  // <= iOS6
}
Ibis answered 26/11, 2013 at 14:54 Comment(1)
This way is suggested by Apple in iOS 7 transition guide.Imperfection
G
3

You can create a makro for solve this problem. it is useful for me.

#define iOS7Delta (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 ) ? 20 : 0 )
Gallery answered 27/11, 2013 at 9:38 Comment(0)
T
-2

If the view's embedded in a UINavigationController - simply untick "Translucent" for your root navigation bar.

In storyboard, select Navigation Controller Scene, next select Navigation Bar and in Attributes Inspector (Utilities - 4 tab) untick "Translucent"

Toombs answered 10/12, 2013 at 15:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.