Majster
Majster

Reputation: 3701

auto layout button position

I have a simple problem with the new Auto Layout feature. I have an app that wil work on the iphone 4, 4s and 5. I need to position a button on the screen and the button needs to be 302 pixels from the buttom at 4 inch screen and 282 pixels at 3.5 (both speaking at retina resolution). How do I accomplish this?

I found a cupple of tutorials but none of them seems to be covering this what I am after. Any ideas?

Upvotes: 1

Views: 408

Answers (1)

sixstatesaway
sixstatesaway

Reputation: 1106

if you're building for less than iOS 6.0 the app will crash if you use autolayout. It will only work on iOS 6.

That said, how I've dealt with different screen heights while supporting older versions of iOS:

You make a macro

#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )

and can check like this.

if( IS_IPHONE_5 )
{ 
    //position the button 302 px from bottom of the screen
}
else
{ 
    //position the button 282 pixels from the bottom of the screen
}

this question helped me

Upvotes: 1

Related Questions