的UITabBarController是的UIViewController的子类。为了解决你的问题只要继承或添加类别您的UITabBarController实现:
@interface UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end
@implementation UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
@end
如果你想使用TabBar只旋转为纵向倒挂只是用个下面的代码,而不是
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
你能解释一下什么我应该这样做,我是一个新手在iOS –
是啊,首先阅读有关类别在这里:http://macdevelopertips.com/objective-c/objective-c-categories.html –
我编辑我的答案,所以你可以看到您应该使用的类别。请告诉我,如果它运作良好的运气 –