gpt4 book ai didi

objective-c - 在 iPad 上旋转时如何阻止模态视图消失?

转载 作者:可可西里 更新时间:2023-11-01 03:58:36 24 4
gpt4 key购买 nike

我正在使用 willRotateToInterfaceOrientation 在我的 iPad 旋转时交换 View 。如果我的设备旋转和交换 View 时打开了模态视图或警报 View ,则 View 交换并且警报消失并且不会重新出现,即使稍后再次“显示”警报也是如此。

编辑:我已经缩小了这个问题的范围。当使用 UIModalPresentationFullScreen 呈现模态视图时,模态视图“幸存”旋转。

我该怎么做才能解决这个问题?

这是我对 willRotateToInterfaceOrientation 的实现:

- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{

[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

//
// Load an alternate view depending on the orientation
//


if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {

[UIView beginAnimations:@"" context:nil];
[self setView:theLandscapeView];
self.view.bounds = CGRectMake(0, 0, 1024, 768);
self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (-90));
[UIView commitAnimations];

}else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {

[UIView beginAnimations:@"" context:nil];
[self setView:theLandscapeView];
self.view.bounds = CGRectMake(0, 0, 1024, 768);
self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (90));
[UIView commitAnimations];

}else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {

[UIView beginAnimations:@"" context:nil];
[self setView:thePortraitView];
self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (0));
self.view.bounds = CGRectMake(0, 0, 768, 1024);
[UIView commitAnimations];

}else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {

[UIView beginAnimations:@"" context:nil];
[self setView:thePortraitView];
self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (180));
self.view.bounds = CGRectMake(0, 0, 768, 1024);
[UIView commitAnimations];
}
}

最佳答案

如果我要解决这个问题,我会执行以下操作之一

  1. 将备用 View 添加到父 View ,并且不更改 View 属性
  2. 为不需要完整 View 交换但重新排列或隐藏 View 子元素的 View 设计。
  3. 呈现层次结构的根 ViewController 中的任何模式

我会非常努力地避免为了方向而完全交换 View 。即使您解决了这个问题,它似乎仍会继续出现问题。

关于objective-c - 在 iPad 上旋转时如何阻止模态视图消失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4988731/

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