2012-08-08 63 views
1

我正在開發一個iPad項目,我想處理兩種模式的縱向和橫向視圖。更改UIBarButtonItem的位置

當我進入橫向模式時,UIBarButtonItem不改變位置。有沒有一種方法可以移動此按鈕並將其放置在酒吧的右側?

肖像:

enter image description here

景觀:

enter image description here

謝謝。

回答

1

解決這樣的問題:

willAnimateRotationToInterfaceOrientation方法我寫道:

if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){ 
     //Change the position of the profil button 
     [self changeProfilButtonOrientation]; 
    }else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown || toInterfaceOrientation == UIInterfaceOrientationPortrait){ 

    } 

而且我changeProfilButtonOrientation方法

-(void) changeProfilButtonOrientation{ 
    UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 
    [self.toolBar setItems:[NSArray arrayWithObjects:flexibleSpace,profilButton, nil]]; 
} 

和它的作品:-)

1

我認爲現在的位置設定如下舔:

ss

在此設置下左邊距的長度被採用橫向模式。所以你必須設置右邊距的長度,並讓這個botton放在導航欄的右端。

你最好設置如下設置:

ss

您可以編輯這些設置由尺寸檢查(請看看這個自己)。

我對這個建議是幫助你。

+0

謝謝你的回答,2張圖片XD之間沒有區別...你能更新你的答案嗎? – 2012-08-08 12:57:14

+0

對不起,我犯了一個錯誤。 – weed 2012-08-08 13:01:45

+0

問題已解決,請看下面的答案:)! – 2012-08-08 13:14:13