gpt4 book ai didi

iphone - 手动将屏幕旋转到横向,屏幕左侧会留下一个白色条,旧状态栏所在的位置

转载 作者:行者123 更新时间:2023-11-29 13:43:52 24 4
gpt4 key购买 nike

我的应用程序中有一个屏幕需要纵向显示,因为我在这个屏幕上使用摄像机。

所以我加载我的 View 然后调用这个方法:

- (void)rotate
{
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90));
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +80.0);

[self.tabBarController.view setTransform:landscapeTransform];
self.tabBarController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight;
self.tabBarController.view.bounds = CGRectMake(0.0, 0.0, 480.0, 320.0);
self.tabBarController.view.center = CGPointMake (240.0, 160.0);
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
}

屏幕左侧有一个 20 像素宽的白色区域,当屏幕处于纵向模式时,状态栏曾经在此处绘制。

将上面代码中的self.tabBarController.view换成self.view也出现同样的问题如果 self.view 不是那个 View ,也许有某种方法可以定位应用程序的 Root View 。

此 View 的 xib 大小为 480 像素。任何人都可以就如何解决这个问题给我一些建议吗?

当我取出这个 View 并使其出现在一个没有任何导航栏的应用程序中并直接放置在主视图上时,它转换正常,左侧没有空白。

非常感谢,-代码

最佳答案

您应该信任 iOS 默认方向更改的旋转。

为了以编程方式旋转到所需的方向:

//set statusbar to the desired rotation position
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:NO];

//present/dismiss viewcontroller in order to activate rotating.
UIViewController *mVC = [[[UIViewController alloc] init] autorelease];
[self presentModalViewController:mVC animated:NO];
[self dismissModalViewControllerAnimated:NO];

希望对您有所帮助!

P.S.在 sdk 3.2.5 ios 5.0.1 上测试。

关于iphone - 手动将屏幕旋转到横向,屏幕左侧会留下一个白色条,旧状态栏所在的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8235285/

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