2013-04-08 2 views
0

Авторотация не работает в ios6.1. Но следующий код работает в другом приложении.Авторотация не работает ios6.1

код:

@implementation UINavigationController (RotationIn_IOS6) 

-(BOOL)shouldAutorotate 
{ 
    return [[self.viewControllers lastObject] shouldAutorotate]; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return [[self.viewControllers lastObject] supportedInterfaceOrientations]; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation]; 
} 

@end 


- (BOOL)shouldAutorotate 
{ 
    //returns true if want to allow orientation change 
    return TRUE; 


} 
- (NSUInteger)supportedInterfaceOrientations 
{ 
    //decide number of origination tob supported by Viewcontroller. 
    return UIInterfaceOrientationMaskAll; 


} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    //from here you Should try to Preferred orientation for ViewController 

    return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationPortrait; 
} 

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration 
{ 

} 
+0

Проверьте настройки проекта для разрешенных ориентации - все поддерживаемые должны быть выбраны, проверьте мой ответ здесь http://stackoverflow.com/questions/15835084/restricting-autorotation-on-defined-views/15835584 # 15835584 – Stas

+0

Да Я выбрал всю ориентацию. Но не работает – Ram

+0

Вы реализовали этот метод в контроллерах, которые должны фактически вращаться? – Stas

ответ

1

ios6 использует главным образом варианты plist для авторотации. Попробуйте настроить поля поддерживаемых ориентаций.

0

Пожалуйста, проверьте ваши цели проекта, как летний ниже

enter image description here

+0

Я уже делал выше метод – Ram

+0

- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation { возвращение ДА; } – dhaya

+0

- (BOOL) shouldAutorotate { возвращение ДА; } – dhaya