0

我创建了 TTPhotoViewController 的子类,当我旋转 iPhone 时,当前图像也被旋转,但不是导航栏和工具栏(带有上一个和下一个按钮的栏)。在我的子类中,我覆盖了该shouldAutorotateToInterfaceOrientation:方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {   
    return  YES;
}

我试图覆盖 willRotateToInterfaceOrientation:duration: e 在里面设置了一个断点,但似乎从未调用过这个方法。

4

2 回答 2

1

确保您的所有视图控制器,即父视图控制器都允许旋转.. 很可能是因为一个或多个视图控制器没有为 shouldAutorotateToInterfaceOrientation 返回 TRUE

于 2011-02-20T22:29:42.200 回答
1

我解决如下:

TTPhotoViewController在 a 内TabBarController,默认情况下TabBarController不会返回YESfor shouldAutorotateToInterfaceOrientation。所以只需继承 TabBarController 并执行以下操作:

@implementation CustomTabBarController

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

@end

我添加了一个小细节:在我第一次尝试旋转界面时,我发现deviceOrientationDidChange:inTTScrollView.m已被删除,这是因为如果您取消此代码,滚动视图在横向旋转时会出现奇怪的行为。

于 2011-02-21T19:11:51.300 回答