【发布时间】:2010-08-29 19:14:34
【问题描述】:
我有一个有 4 个视图的 TabBarController 应用程序。 我已经在所有 4 个 viewControllers 上设置了 autorotate 方法返回 yes :
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return YES;
}
多亏了这一点,现在当我旋转 iPhone 时,旋转可以正常工作,甚至 TabBar 也会旋转。
在每一个视图中,我都可以使用以下代码更新以查看何时发生旋转:
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[self adjustViewsForOrientation:toInterfaceOrientation];
}
- (void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation {
if (orientation == UIInterfaceOrientationLandscapeLeft ||
orientation == UIInterfaceOrientationLandscapeRight) {
//Here i can update the view when it goes to landscape
}
else if (orientation == UIInterfaceOrientationPortrait ||
orientation == UIInterfaceOrientationPortraitUpsideDown) {
//Here i can update the view when it goes to portrait
}
}
问题是当我进行旋转时,只有当前显示的视图在更新。如果稍后我单击 tabBar 更改视图,我会看到视图未针对新方向更新。
有没有办法让所有知道方向的视图都改变了?
【问题讨论】:
标签: iphone