1

我正在开发一个 iPad 项目,我想同时处理纵向和横向两种模式。

当我进入横向模式时,UIBarButtonItem不会改变位置。有没有办法移动这个按钮并将其放在栏的右侧?

肖像 :

在此处输入图像描述

景观 :

在此处输入图像描述

谢谢你。

4

2 回答 2

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]];
}

它有效:-)

于 2012-08-08T13:13:49.413 回答
1

我认为目前的位置设置如下:

ss

在此设置下,左边距的长度采用横向模式。所以你必须设置右边距的长度,让按钮放在导航栏的右端。

您最好将设置设置如下:

ss

您可以通过尺寸检查器编辑这些设置(请自行查看)。

我的这个建议对你有帮助。

于 2012-08-08T12:53:34.977 回答