How to force view controller orientation in iOS 8?

前端 未结 25 2101
太阳男子
太阳男子 2020-11-22 13:11

Before iOS 8, we used below code in conjunction with supportedInterfaceOrientations and shouldAutoRotate delegate methods to force app orie

25条回答
  •  太阳男子
    2020-11-22 13:25

    This is what worked for me:

    https://developer.apple.com/library//ios/documentation/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/clm/UIViewController/attemptRotationToDeviceOrientation

    Call it in your viewDidAppear: method.

    - (void) viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    
        [UIViewController attemptRotationToDeviceOrientation];
    }
    

提交回复
热议问题