0

All the pages of the app should be in portrait mode. But in a particular page, I am loading a you tube video in a webview. When the video is clicked, I am showing the video in mpmovie player controller and I want this in a landscape mode. How can I do this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Rafay
  • 99
  • 2
  • 10
  • Maybe, here you can find an answer http://stackoverflow.com/questions/20372223/maintain-one-view-controller-in-portrait-and-other-in-landscape-mode-ios http://stackoverflow.com/questions/16392021/first-uiview-in-portrait-orientation-and-second-in-landscape?rq=1 – Oleshko Sep 22 '14 at 08:04
  • Check my answer for the similar question- http://stackoverflow.com/questions/23491426/ios-7-how-to-allow-only-portrait-orientation-for-vc/23491583#23491583 – Bharat Sep 22 '14 at 11:59

2 Answers2

0

You have to put this lines in your view controller's viewdidload that you need to be in landscape mode i think that will work ...

 if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
    objc_msgSend([UIDevice currentDevice], @selector(setOrientation:),    UIInterfaceOrientationLandscapeLeft );
}
Deep Gami
  • 508
  • 3
  • 13
0

If you're using storyboard you can just select your view and in the attributes inspector you can select the orientation you want (instead of "Inferred").

If you're not in storyboard i'm pretty sure you can use something like this

webview.orientation = UIOrientationPortrait   (haven't tried it but it must be pretty similar)
Gil Sand
  • 5,802
  • 5
  • 36
  • 78
  • Does this help ? http://stackoverflow.com/questions/2325795/webview-resizes-automatically-to-portrait-and-landscape-view-in-iphone its about resizing the webview once rotated, so you should be able to see how it rotates with the shouldAutorotateMethod. But it needs testing and i don't have time right now, i'm just trying to find a path to show you – Gil Sand Sep 22 '14 at 11:38