2012-10-21 147 views
1

我有一個簡單的問題與新的自動佈局功能。我有一個應用程序,將在iphone 4,4s和5的工作。我需要在屏幕上放置一個按鈕,按鈕需要從4英寸屏幕buttom 302像素和282像素3.5(均在視網膜說話解析度)。我該如何做到這一點?自動佈局按鈕位置

我發現了一個教程的cupple,但他們沒有一個似乎覆蓋了我所追求的。 任何想法?

回答

1

如果您構建的是iOS 6.0以下版本,則應用程序會在使用自動佈局時崩潰。它只會在iOS 6

這就是說,我是如何處理不同的屏幕高度的工作,同時支持舊版iOS:

你讓宏

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

,可以像檢查這個。

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