Search code examples
objective-cuiwebviewlandscapeuiwindow

How Can I set UIWebview or UIWindow in Landscape Mode in Global function?


I cannot use viewcontroller because viewcontroller crushed to unity(Game engine's name)'s application somehow. I needed to make my objective-c view in landscape to match unity's display.

I have searched on internet but what I found is force setting in controller. So I want set UIWebView or UIWindow in Landscape mode for iphone inside global function. How Can I set the code for that?


Solution

  • Setting a UIView or UIWindow in landscape mode is simply a matter of drawing the view in landscape orientation.

    What view controllers add is simply the possibility of handling the rotation in a specific way (allowing it or preventing it), but the end responsibility to draw in landscape/portrait is with your view.

    As a concrete suggestion, you can try and use a CGAffineTransformation to rotate your view, if it makes things easier for you:

        CGAffineTransform newTransform;
        newTransform = CGAffineTransformMakeRotation(M_PI/2);
        view.transform = newTransform;
    

    but without further hints as to how your view is made up, I cannot help more.