Video orientation after launched from UIWebView - iphone

I have an UIWebView that has an youtube's embed code (iframe). I'd like to enable both portrait and horizontal orientation for the video player, but portrait mode only for the UIWebView itself.
How can I achieve this?

The UIWebView displays its content by its orientation. There is no (easy) way to conditionally change which orientations the UIWebView allows based on its content. The only way I can imagine this working is by parsing the HTML of the web view and based on its content, allowing or disallowing certain orientations.
Regardless of all this, I would suggest either allowing both portrait and landscape for both, or only allowing portrait. This would be confusing to users if you only sometimes allowed landscape.

Related

Force iphones and ipads into landscape mode via a web based layout

Is there a way to force ipads and iphones to render the web based layout in landscape mode only?
You have to prevent the view from rotating with:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return NO;
}
then you have to initiate the view in landscape this way you will prevent the view from rotating.
You can't force Safari to stay in a specific orientation, but you can detect it.
body[orient="landscape"] or body[orient="portrait"] can be used in your CSS to render two different layouts. If you choose, one of them (portrait in this case) can display a "not optimized for this layout" screen of some sort.
I suppose you could try to do a -webkit-transform: rotate(-90deg) on the body of the page, but if the page scrolls that probably would not be feasible. If your layout was exactly the right size, though, it might look pretty close to correct.

Orientation issue in webview

I am opening an url in my universal application in a web view with orientation enabled, in portrait orientation first time the website load properly but when I change the orientation from portrait to landscape its working properly but when come back from landscape to portrait the website's contents of bottom dose not load, its working properly in iPod's, and iPhone both orientation properly but only iPad portrait orientation the bottom content dose not load when I change orientation, and when I open this url in my iPad safari browser all things working properly, please help me someone.
Thanks in Advance,
Rameshu

different theme for landscape and portrait mode

Let me explain what I am creating and it will be nice if someone could tell me a better approach.
I am creating an app that supports all orientations. The app is like a power point presentation with several slides with several images and basic functionality in each slide. the functionality is very simple such as showing an image or moving an image when a button is pressed for example. So creating the app is not the problem. Since this app has to support all orientations when the device enters portrait mode I need to move the content in order to make it fit for the portrait orientation. And I would have to do the same thing if it enters landscape mode. Because there is so much content in every slide I need to change the content very much when changing orientation. so an image in portrait mode might have cords (20,5) and on landscape mode that image will have totally different coordinates.
So is there a way that I can set the IBOutlets have specific cords on landscape and specific cords on portrait with xcode. It takes me forever to store the cords of every IBOutlet in an array since I have so many IBOutles in each slide. I have to store the CGPoints in an array with the cords of IBOutlets in landscape and portrait mode and then if the device enters landsape mode set it's center equal to the array elemets. THIS IS SIMPLE BUT IT TAKES FOREVER!
Moreover I am creating many xib files and treat each xib as a different slide in my app.
With what you are saying, you need two xibs for each "slide". One that describes the portrait orientation, and one that describes the landscape orientation.

iPhone, playing a movie in landscape but return to portrait when movie is complete

Total Objective-C/XCode N00b here but I am attempting something, which I assume is simple. I have an app that is written for the iPhone, I don't allow auto orientation and only have the main interface locked into portrait. When the user plays a video in the app I would like to allow them to auto rotate the device from portrait and watch it in landscape (should they choose to do so, I don't want to force this). Once the user presses "Done", I would like to force them back into portrait (even if they are holding the device in landscape) as the interface is only laid out in that orientation.
I've tried using the MPMoviePlayerController and MPMoviePlayerViewController and I am not sure which will give me the leverage/methods I need. I am basically just looking to allow shouldAutorotateToInterfaceOrientation to return yes only when the MPMoviePlayerController view is visible.
Any help MUCH appreciated. Thanks.
I used this code example and it worked perfectly. I think you'll have to set the orientation in the super class.

iphone: reloading webview with rotation

i'm using uiwebview to display a very basic html page with just text. i want to support landscape and portrait orientations but i'm having a problem with resizing when the orientation changes. specifically, when the iphone is rotated to landscape, it zooms in on the text (i want the text size to remain the same and for it to fill the wider horizontal space). when it is rotated back to portrait, the text returns to the correct size but now it flows off the page to the right.
i think the solution is to reload the page with each change in orientation. is there a way to reload the page each time the iphone is rotated?
You can call reload on the web view when the view controller receives either of these methods:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
You could try setting scalesPageToFit=NO in the web view. You have fairly fine grained control of the webview from the html. Look at the viewport and other meta tags you can use.