gpt4 book ai didi

iphone - willAnimateRotationToInterfaceOrientation 未在一个 subview 中调用,而另一个 subview 可见并已旋转

转载 作者:行者123 更新时间:2023-12-01 18:33:52 26 4
gpt4 key购买 nike

我在 UITabBarController 中有 3 个 subview 。第一个选项卡的 View 具有在调用 willAnimateRotationToInterfaceOrientation 时手动移动的对象。但是,如果另一个选项卡的 View 在旋转时可见,则将永远不会调用 willAnimateRotationToInterfaceOrientation,并且如果我返回第一个选项卡,则第一个选项卡 View 上的项目不在正确的位置。

当另一个 View 可见时,如何在旋转时手动移动一个 View 中的对象?

最佳答案

我解决了。我所做的是创建一个从 ViewWillAppear 调用的方法,该方法获取当前方向并更改屏幕上的对象位置。

希望这可以帮助某人。

- (void)manuallyMoveViewObjects{

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
CGRect buttonFrame = CGRectMake(125.0, 223.0, 70.0, 50.0);

self.button.frame = buttonFrame;
}

else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
CGRect gbuttonFrame = CGRectMake(205.0, 131.0, 70.0, 50.0);
self.button.frame = buttonFrame;

}

}

关于iphone - willAnimateRotationToInterfaceOrientation 未在一个 subview 中调用,而另一个 subview 可见并已旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4009813/

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