gpt4 book ai didi

iphone - 使用 AutoLayout 进行旋转

转载 作者:太空狗 更新时间:2023-10-30 03:38:23 27 4
gpt4 key购买 nike

我是 Xcode 的初学者,我正在使用 ios6 和自动布局。

我想从以下位置旋转我的 uiviewcontroller:

enter image description here

到:

enter image description here

我想防止底部栏旋转。与 Apple 的相机应用程序旋转非常相似,但出了问题的是一切都在旋转。

我试着把一些代码放在

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{   
// [Bar setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
// [Bar setTranslatesAutoresizingMaskIntoConstraints:YES];
}

最佳答案

我不知道IB是怎么实现的,但是你可以通过代码添加特定的约束来实现:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
[self.view removeConstraints:landscapeConstraints];
} else {
[self.view addConstraints:landscapeConstraints];
}
}

关于iphone - 使用 AutoLayout 进行旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12588048/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com