2012-08-08 78 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