iOS Question VideoView force to landscape view in portrait only app?

Discussion in 'iOS Questions' started by yonson, Mar 3, 2015.

  1. yonson

    yonson Active Member Licensed User

    I have an app that has a number of modules, and is restricted to portrait mode only.

    However, one module plays videos, and these are always in landscape mode, so I need to re-orientate accordingly.

    I was wondering the best approach to achieve this. I have had 2 thoughts about how this could be achieved:-

    • allow the app to support all orientations, but 'block' the event when a rotation happens (I'm not sure what event is raised) apart from in the video view page
    • force the videoview to rotate to landscape mode by bypassing the portrait only restriction somehow (this is what we do in the B4A solution)
    I know this is possible in B4a (if anyone requires the code please contact me) but various functions aren't supported on iOS (e.g. SetScreenOrientation in the phone library).

    Any thoughts?
    Thanks
    John
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Currently the video plays in portrait and is too small?

    I don't think that you can bypass the portrait only restriction.

    It is possible to programmatically change the orientation. It uses a non-public API so Apple may reject your app (my guess is that it will be fine):
    Code:
    Sub SetOrientation(landscape As Boolean)
       
    Dim no As NativeObject
       
    Dim value As Int
       
    If landscape Then value = 4 Else value = 1
       no.Initialize(
    "UIDevice").RunMethod("currentDevice"Null).SetField("orientation", value)
    End Sub
     
  3. Pendrush

    Pendrush Well-Known Member Licensed User

    I have used Erel's code to show only VideoView page in landscape, app is "forced" to be in portrait mode.
    My app passed review.
     
    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice