旋转我的视图控制器时,状态栏不会随 with 一起旋转。如何解决?



每个人。我有一个iOS6 ipad应用程序要更新。我遇到的问题是,只有一个视图控制器需要自动旋转,而且我找不到正确的方法。

我尝试了以下链接,它在一定程度上起到了帮助:xcode中只有一个视图自动旋转?

但是,当我旋转viewController时,它的状态栏不会随视图一起旋转,视图的标题也不会像我设置的那样位于中心。

我在viewController中添加了断点,发现只有当设备处于横向时,它才会调用- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

我想知道是否有人能告诉我这个bug藏在哪里以及如何修复。谢谢。

我已经解决了这个问题。我的错误是,在设置自转问题时,我在下面添加了一些单词。

CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(0));
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, 0.0, 0.0);
self.view.bounds = CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y, 768, 1024);
if (isVisible == NO) return; // iOS present modal bodge
[self updateScrollViewContentViews]; // Update content views
lastAppearSize = CGSizeZero; // Reset view size tracking
[self.view setTransform:landscapeTransform];

我删除了这些手动文字,并保留了以下方法。它完成了。

-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}
- (BOOL)shouldAutorotate
{
    return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

最新更新