2010-06-18 2 views
0

Я работаю над приложением, которое состоит из контроллера TabBar. Внутри своей вкладки у меня есть подкласс UITableViewController, внутри этого списка у меня есть график основного графика в первой ячейке и некоторые другие данные в 4 следующих ячейках. Когда я вернусь ДА в методе shouldAutorotateToInterfaceOrientation, я бы ожидал, что произойдет автоматическая сортировка списка, но ... ничего. Когда я добавляю некоторый журнал в метод 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

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; 
}