Customising the UIViewController for PageRenderer on iOS 8 to Rotate/Prevent rotation

Stan_OkunevicStan_Okunevic GBUniversity ✭✭

Hello comrades,

I'm working on a project, which initially had the requirement of being Portrait-only. That was fine, I had simply set it to only support Portrait on iOS project settings. Now the application has a few screens which are meant to be Landscape-only, meaning that I had to re-enable Landscape mode in my application settings.

On my main page (the portrait-only one) I have set ShouldAutorotateToInterfaceOrientation, PreferredInterfaceOrientationForPresentation, GetSupportedInterfaceOrientations and WillRotate to work only with Portrait mode, but it's still rotating to Landscape absolutely fine. Setting ShouldAutorotate to either true or false did not seem to have any effect.

A post on these forums (can't seem to find it at the moment) did recommend creating a custom controller that inherits from UIViewController and editing that, but the controller does not appear to be changeable on a PageRenderer.

Has anyone faced a similar situation? Assistance would be incredibly appreciated.

Best Answer

  • adamkempadamkemp US mod
    Accepted Answer

    You can't do it directly from the custom page renderer using GetSupprtedInterfaceOrientations because of this bug. However, you can do it from the app delegate, and you can have your custom page renderer communicate with the app delegate to tell it to update its supported interface orientations.

Answers

  • adamkempadamkemp USInsider, Developer Group Leader mod
    Accepted Answer

    You can't do it directly from the custom page renderer using GetSupprtedInterfaceOrientations because of this bug. However, you can do it from the app delegate, and you can have your custom page renderer communicate with the app delegate to tell it to update its supported interface orientations.

  • Stan_OkunevicStan_Okunevic GBUniversity ✭✭
    edited September 2015

    @adamkemp I tried overriding it on AppDelegate as well. The issue is unfortunately still there.

    Edit.: Seems to be starting to work. Will post an update tomorrow.

  • Stan_OkunevicStan_Okunevic GBUniversity ✭✭

    It worked! Thanks a bunch, @adamkemp

  • MiaoTomMiaoTom USMember

    @Stan_Okunevic said:
    It worked! Thanks a bunch, @adamkemp

    hi, Stan_Okunevic,can you tell me how can i use app delegate to do it.

Sign In or Register to comment.