Reputation: 198
i am defining the macro at my Appdelegate , here is my code
let IPHONE = UIDevice.currentDevice().userInterfaceIdiom == .Phone
let IPAD = UIDevice.currentDevice().userInterfaceIdiom == .Pad
#if IPHONE
let LEFT_DRAWER_HEIGHT : CGFloat = 270.0
#elseif IPAD
let LEFT_DRAWER_HEIGHT : CGFloat = 404.0
#else
let LEFT_DRAWER_HEIGHT : CGFloat = 404.0
#endif
but it always returns LEFT_DRAWER_HEIGHT = 404.0 rather i have run in iphone device. whats the mistake? can anyone figure it out.
Upvotes: 0
Views: 667
Reputation: 9397
Do you have separate targets for iPhone and iPad? And are you defining those constants in each of those targets?
#if
is a compile time conditional, so if you have a universal app, the compiler can't know at compile time what device will the app run on. You should instead use a normal if condition.
Upvotes: 2