2013-07-27 3 views
3

Я хотел бы знать, как я мог бы заблокировать ориентацию для моего основного контроллера просмотра, но разрешить моим пользователям вращаться в ландшафт для всех контроллеров View?Заблокировать ориентацию только для основного UIViewController - iOS

Спасибо заранее!

ответ

3

Для MainViewController:

-(NSUInteger)supportedInterfaceOrientations 
    { 
     return UIInterfaceOrientationMaskPortrait; 
    } 

Другие ViewControllers

-(NSUInteger)supportedInterfaceOrientations 
    { 
     return UIInterfaceOrientationMaskLandscape; 
    } 
+0

Ваш лучший! Мне просто нужно было изменить UIInterfaceOrientationMaskLandscape для второго в UIInterfaceOrientationMaskAll. Еще раз спасибо! –

0
- (NSUInteger)supportedInterfaceOrientations { 
    UIInterfaceOrientationMaskPortrait 
} 

по умолчанию для IPad является

UIInterfaceOrientationMaskAll 

в то время как iPhone по умолчанию

UIInterfaceOrientationMaskAllButUpsideDown 

вам не нужно осуществить что-нибудь еще на других контроллерах просмотреть

0

Это может помочь вам ..

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

-(BOOL)shouldAutorotate{ 
return NO; 
} 
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ 
return UIInterfaceOrientationPortrait; 
} 
Смежные вопросы