2011-01-21 27 views
0

我的iPhone應用程序有兩個內容框。當用戶切換的手機包裝盒的方向改變這樣的位置:iPhone方向 - 兩個盒子

肖像

|---------| 
| BUTTON1 | 
| BUTTON2 | 
|---------| 
|   | 
| BUTTON3 | 
| BUTTON4 | 
|   | 
|---------| 

景觀

|---------|---------------| 
| BUTTON1 | BUTTON3 | 
| BUTTON2 | BUTTON4 | 
|---------|---------------| 

什麼是正確的方式去?兩個XIB,其他技巧?我應該在代碼中手動調整元素大小嗎?

回答

2

使用這樣的事情:

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ 
if(toInterfaceOrientation == UIInterfaceOrientationPortrait){ 
    button.frame = CGRectMake(20,20,125,125); 
    }else{ 
    button.frame = CGRectMake(20,20,125,125); 
    } 
} 

當然,你必須使用你自己的尺寸在CGRectMake框中,但除此之外,我希望這有助於。

+0

好,所以你建議我用代碼手動調整它們的大小? – xpepermint 2011-01-21 21:44:13

0

您可以在視圖控制器使用此方法:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration; 

要調整箱「/視圖」框架。我相信他們會自動生成動畫。

查閱文檔以獲取更多信息。

+0

嗡嗡......好吧,這只是旋轉開始時調用的函數。問題是如何調整框的大小。這個盒子有像按鈕,其他元素的內容。 – xpepermint 2011-01-21 21:38:15