2010-06-18 77 views
0

我正在处理由TabBar控制器组成的应用程序。 在它的选项卡中,我有一个UITableViewController的子类,在这个列表中,我在第一个单元格中有一个Core-plot图形,在下面的4个单元格中有一些其他数据。 当我在shouldAutorotateToInterfaceOrientation方法中返回YES时,我期望列表视图的自动调整发生,但是......什么也不做。 当我在willRotateToInterfaceOrientation方法中添加一些日志时,它们不会显示。 有什么我错过了吗? 非常感谢, 吕克iphone无法在TabBar控制器中旋转视图

// Override to allow orientations other than the default portrait orientation. 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
// Return YES for supported orientations 
//return (interfaceOrientation == UIInterfaceOrientationPortrait); 
NSLog(@"Orientation"); 
return YES; 
} 
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; 

NSLog(@"Rotating"); 

if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
{ 
    NSLog(@"view land:%@", self.view); 
} 

if (toInterfaceOrientation == UIInterfaceOrientationPortrait) 
{ 
    NSLog(@"view portrait:%@", self.view); 
} 
} 

回答

2

是,除非你继承UITabBarController和正确地覆盖其shouldAutorotateToInterfaceOrientation:方法将无法正常工作。

参见my question here and related answers

+0

非常感谢Luc – Luc 2010-06-19 21:05:02

0
add this method in category 
@implementation UITabBarController(UITabBarControllerCategory) 

-(BOOL)shouldAutorotateToInterfaceOrientation: 
(UIInterfaceOrientation)toInterfaceOrientation 
{ 
    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate]; 

    if ([AppDelegate isLandScapeOnly]){ 
    return NO; 
} 
return YES; 
}