简体   繁体   中英

Force UIView/UIVIewController orientation

We're writing an application that's in landscape mode exclusively. We use a transform on a root view to rotate it to LandscapeRight, then every view that gets loaded by that view shares the coordinate system. That's all fine and dandy, except one of our views has a UIWebView object that's being loaded by a view controller. The site that we're trying to look at doesn't have its content filling the view. When I view the same site in mobile Safari in landscape mode, it looks correct. My guess is that the View Controller we're using to host the WebView still thinks it's in portrait mode, as querying the interfaceOrientation of the property returns "1"...is there a way to trick a view/view controller to think it's in a specific orientation?

Hopefully you've already found an answer for this, but you might try telling your app to just start out in landscape mode, rather than forcing it to always rotate to that orientation. Then if your root view's shouldAutorotateToInterfaceOrientation returns yes only for landscape modes, I'd bet you'd have the behavior you're looking for.

This guy seems to have a good tutorial about how to do all that. http://www.dejoware.com/blogpages/files/iphone_programming_landscape_view_tutorial.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM