【问题标题】:iPhone rotation issueiPhone旋转问题
【发布时间】:2011-01-12 07:58:22
【问题描述】:

我正在努力将视图强制为横向模式,并且已经掌握了各种很酷的技巧来实现这一点,但我卡在了留在屏幕上的一个项目上。

我的 XIB 文件以横向布局,在我的代码中我通常创建视图控制器:

RedeemViewController *aViewController = [[RedeemViewController alloc] initWithNibName:@"RedeemViewController" bundle:nil];
    aViewController.hidesBottomBarWhenPushed = YES;
    aViewController.wantsFullScreenLayout = YES;
[[self navigationController] pushViewController:aViewController animated:YES];  

在控制器 viewDidLoad 中,我完成了以下操作:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
[[self navigationController] setNavigationBarHidden:YES animated:YES];


[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:.75];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

if (self.interfaceOrientation == UIInterfaceOrientationPortrait) {      
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
self.view.bounds = CGRectMake(0.0, 0.0, 480, 320);
}
[UIView commitAnimations];

我最终得到的是一个完美旋转的视图,左侧有一个灰色的垂直条(见图)。 alt text http://taxhelp.net/vert_bar.png

那么问题来了,我该如何摆脱酒吧?

编辑:我很确定这是没有被隐藏的导航栏。

【问题讨论】:

    标签: iphone


    【解决方案1】:

    您的边界矩形是以 (0, -20) 为原点创建的。将其更改为 (0, 0),您应该摆脱偏移并让视图充满屏幕。

    【讨论】:

    • 哦,我的错,我正在调试一下,看看是否可以将图像移过来。我在 0.0 处得到相同的结果,将其更改为 -20.0 会使图像向下移动一点,但不会向左或向右移动。这是试图将视图向下移动到状态栏下方,否则状态栏会覆盖视图的顶部。我已经把上面的 -20 去掉了。
    猜你喜欢
    • 1970-01-01
    • 2011-05-11
    • 2011-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多