我正在开发一个iPad项目,我想处理纵向和横向视图两种模式。
当我进入横向模式时,UIBarButtonItem
不会改变位置。是否有方法移动此按钮并将其放在栏的右侧?
肖像:
风景:
谢谢。
答案 0 :(得分:1)
我认为目前的位置设置如下:
在此设置下,横向模式采用左边距的长度。因此,您必须设置右边距的长度,并将按钮放在导航栏的右端。
您最好将设置设置如下:
您可以通过尺寸检查员编辑这些设置(请自行查看)。
我有这个建议对你有帮助。
答案 1 :(得分: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]];
}
它有效: - )