0

I'm using a storyboard with xcode 4.5, building an app on iOS 6. I have a video in an mpvideoviewcontroller. It goes landscape when I view the video, but for all the other views (I have likes songs, and news) how do I make it portrait for all those other tabs? I just want the video to be in landscape. Is there something I am missing, I do. Orientation on every tab to Portrait, on the xcode project summary screen I enable left and right. And I add this line of code for the ones I want to be only in portrait.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
 {
     return NO;
 }

Any suggestions?

FYI: If I change in the summary page of Xcode for orientations to only portrait mode, every view is in portrait, and I want my video view to be in landscape not portrait mode.

jakife
  • 137
  • 1
  • 10
  • I will do more research for you on the topic but I do know though just as a quick response that the iOS 6 SDK the shouldAutorotateToInterfaceOrientation is deprecated and now you should use the - (BOOL)shouldAutorotate method – Zack Sep 22 '12 at 03:35
  • If your problem is related iOS 6 rotation issue than refer [this][1] link. [1]: http://stackoverflow.com/questions/11544382/ios-6-screen-rotation-without-using-storyboard – Ashvin Sep 22 '12 at 05:30

3 Answers3

1

iOS 6 support this one on AppDelegate

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
       // check if you are in video page --> return landscape
       return (isVideoPage)?UIInterfaceOrientationMaskAllButUpsideDown:UIInterfaceOrientationMaskPortrait;
    }

Hope that help.

Trong Dinh
  • 363
  • 4
  • 9
0

Change that method to only return true for portrait mode:

- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation {

    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
James McCracken
  • 15,488
  • 5
  • 54
  • 62
0

I guess you can do something like this where in my code prevLayer is the view with the video feed since this object is AVCapture type it has setOrientation, but you could do a transform/rotate some degree to match the current orientation, hope it helps.

-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    switch ([[UIDevice currentDevice]orientation]) {
        case UIDeviceOrientationLandscapeLeft:
            [self.prevLayer setOrientation:AVCaptureVideoOrientationLandscapeRight];
            break;
        case UIDeviceOrientationLandscapeRight:
            [self.prevLayer setOrientation:AVCaptureVideoOrientationLandscapeLeft];
            break;
        default:
            [self.prevLayer setOrientation:AVCaptureVideoOrientationLandscapeLeft];
            break;
    }

}
Troy Alford
  • 26,660
  • 10
  • 64
  • 82
Ges83
  • 82
  • 6