我找到了答案。至于ios6的定位,有很多links用于实现新的方法。
最初我的观点是不支持旋转,直到我发现我的tabBarController是为应用程序一个RootViewController的,所以我说
(BOOL)shouldAutorotate {return YES; }
在我的子类TabBarController类
在我info.plist中添加的项值对用于支持的接口方向,除非您在当前的UIViewController中指定例外,否则此值将是应用程序的全局值
- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }
为了在UITableView中实现旋转,我调用了reloadData();通过使用
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [self.tableView reloadData]; }
它没有必要写一个自定义的UITableViewCell类,你可以在
– tableView:cellForRowAtIndexPath:
方法重绘细胞。
正如我已经有一个自定义的UITableViewCell类,我通过获得[[UIApplication sharedApplication] statusBarOrientation]
方法在layoutSubviews();
中绘制新单元格。
如果您在单元格内有任何自定义的UIViews,您需要重新绘制矩形以支持横向模式。基本上我也支持ios5,所以我没有通过XIB使用AutoLayout。您还可以根据布局框架为每个子视图使用自动调整遮罩。
reloadData();对于内存来说并不昂贵,因为您不会同时调用所有单元,并且只会重绘UITableView中的可见单元,并且像之前一样重用单元。