Iphone 手动将屏幕旋转至横向,屏幕左侧留下一个白色条,旧状态条放在此处

Iphone 手动将屏幕旋转至横向,屏幕左侧留下一个白色条,旧状态条放在此处,iphone,objective-c,ios,xcode,Iphone,Objective C,Ios,Xcode,我在我的应用程序中有一个屏幕,我需要在这个屏幕上使用摄像机 因此,我加载视图,然后调用此方法: - (void)rotate { CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90)); landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +80.0); [self.ta

我在我的应用程序中有一个屏幕,我需要在这个屏幕上使用摄像机

因此,我加载视图,然后调用此方法:

- (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不是应用程序的根视图,那么可能有某种方法可以定位该应用程序的根视图

此视图的xib大小为480像素。有谁能给我一些关于如何解决这个问题的建议吗

当我将此视图取出并使其显示在没有任何导航栏的应用程序中,并直接放置在主视图上时,它会转换为ok,而不会在左侧留下空白

非常感谢,,
-代码

您应该信任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];
希望这会有帮助


在sdk 3.2.5 ios 5.0.1上进行了测试。

您应该信任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上测试。

您是否尝试先更改方向,然后设置tabBarController的边界??您的代码非常适合medid您尝试先更改方向,然后设置tabBarController的边界??您的代码非常适合我