非常好的問題。當我升級它們以支持iphone 5屏幕尺寸時,我遇到了與我的每個應用程序完全相同的問題。
我最終做的是禁用自動佈局,但我仍然使用故事板來放置我所有的按鈕,視圖,圖像等。我確保在放置所有項目時在故事板中使用了3.5英寸。然後,我將這些UILabel或UIButton等連接到一個IBoutLet,然後在我的ViewDidLoad中查看它的iphone 4 vs iPhone 5,並相應地重新定位所有按鈕。例如
。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
// iPhone Classic
}
if(result.height == 568)
{
// iPhone 5 this is the offset I am using
int yInt = 50;
[blurSlider setFrame:CGRectMake(31, 406+yInt, 271, 34)];
[alphaSlider setFrame:CGRectMake(31, 447+yInt, 271, 34)];
[blurLabel setFrame:CGRectMake(33, 392+yInt, 71, 24)];
[alphaLabel setFrame:CGRectMake(33, 436+yInt, 71, 24)];
}
}
}
我可以在沒有使用故事板的情況下完成所有的編碼嗎?當然,我可以但是我發現故事板的視覺方面吸引人,並且確切地看到所有東西都適合在屏幕上。
你有沒有設置自動佈局? – Volker
是的,在autoLayout的名稱上,我選中了Use AutoLaout複選框。 –
您可能需要學習自動佈局。這是一個很好的自動佈局教程。 http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2 – Sandeep