2015-10-08 2 views

ответ

0

Да, вы можете принудительно настроить ориентацию контроллера вида.

, например ...

class ViewController: UIViewController { 
    override func supportedInterfaceOrientations() -> Int { 
     return Int(UIInterfaceOrientationMask.Landscape.rawValue) 
    } 
} 
0

вы можете добавить этот метод в приложение делегата Пример: -

- (NSUInteger) применение: (UIApplication *) применение supportedInterfaceOrientationsForWindow: (UIWindow *) окно { if ([self.window.rootViewController.presentedViewController isKindOfClass: [SecondViewController class]]) { SecondViewController * secondController = (SecondViewCo ntroller *) self.window.rootViewController.presentedViewController;

if (secondController.isPresented) 
     return UIInterfaceOrientationMaskAll; 
    else return UIInterfaceOrientationMaskPortrait; 
} 
else return UIInterfaceOrientationMaskPortrait; 

}

Более подробно смотрите ссылку: ->http://swiftiostutorials.com/ios-orientations-landscape-orientation-one-view-controller/

0

вы можете попробовать с этим кодом в ViewController, который вы хотите быть в ландшафтном режиме. Также не забудьте добавить ландшафтный режим в info.plist в ориентации поддерживаемого интерфейса.

- (void)viewWillAppear:(BOOL)animated{ 
BOOL pushed = [self isMovingToParentViewController]; 

if (pushed && [[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) 
{ 
    NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]; 
    [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; 
}} 

- (void)viewWillDisappear:(BOOL)animated{ 
BOOL popped = [self isMovingFromParentViewController]; 

if (popped && [[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]){ 
    NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait]; 
    [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; 
}} 
Смежные вопросы