【发布时间】:2013-12-03 13:02:44
【问题描述】:
我正在为该项目使用情节提要。
我有一个带有 3 个按钮的顶部菜单(UIView,其中包含 3 个UIButton),它们之间的距离相同。
我想在旋转时将此菜单拉伸到最大宽度并增加按钮之间的距离。
我做了以下事情:
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)orientation {
[super didRotateFromInterfaceOrientation:orientation];
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
if (UIDeviceOrientationIsLandscape(deviceOrientation)){
[self prepareLandscapeLayout];
}
}
- (void) prepareLandscapeLayout {
[[self topMenu] setFrame:CGRectMake(0, 0, IS_IPHONE_5 ? 568 : 480, 59)];
[[self cameraButton] setCenter:CGPointMake(232, 26)];
[[self settingsButton] setCenter:CGPointMake(288, 26)];
[[self videoList] setCenter:CGPointMake(340, 26)];
}
prepareLandscapeLayout 函数在旋转后被调用,但按钮保持在原来的位置。我还可以看到topMenu 在旋转后如何拉伸(我已经更改了背景颜色)。
对我可能做错的事情有什么想法吗?
【问题讨论】:
-
设置按钮的中心不会拉伸它,它只会移动它。像使用顶部菜单一样更改按钮的实际框架
-
@danypata 我不想调整它们的大小,我只需要将它们放到新位置
标签: ios objective-c layout