旋转TabBarController的所有视图
问题描述:
我有一个带有4个视图的TabBarController应用程序。 我已经把所有的4个viewControllers自动旋转方法返回的是:旋转TabBarController的所有视图
-(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,我看到视图未更新为新的方向。
有没有办法让所有的视图知道方向改变?
答
好吧,我发现它! = d
诀窍是使用功能:
- (void)viewWillAppear:(BOOL)animated
只是把它在你的viewControllers,并插入里面的代码更新视图。请享用!
将此标记为已回答。 – bstahlhood 2010-08-30 02:14:51
我必须等到明天才能做到! – Abramodj 2010-08-30 07:21:36
我怀疑这只发生在你已经访问过的视图上,而不是你第一次访问过的视图。 – fogelbaby 2010-10-19 02:26:49