0

I have a tab bar app, and my viewcontroller for one of my tabs loads a webview to a youtube video. I don't know why I can't rotate when I click play and try to watch the video.

Here is my code

//
//  TefViewController.m
//  SephardiJews
//
//  Created by Yuval Marcus on 7/19/12.
//  Copyright (c) 2012 iOS Developer, Chief Writer at Sephardijews.com. All rights reserved.
//

#import "TefViewController.h"

@implementation TefViewController
@synthesize tef;

-(void)viewDidLoad {
    [super viewDidLoad];
    [tef loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=YSuH69FlXiM"]]];

}

// Can't rotate landscape
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
@end
jakife
  • 137
  • 1
  • 10

2 Answers2

0

The tabbarcontroller does not autorotate to landscape, unless all of the root controllers support the same orientation. You should write

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation{
    return YES;
}

on all the parents of the viewcontroller you want to rotate (this includes the uitabbarcontroller).

m.piras
  • 345
  • 1
  • 2
  • 19
0

Supporting rotations are dictated by the parent controller (Nav Controller, TabBar Controller, View Controller, etc), unless the child controller says differently. If you want to support certain orientations, simply override the

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation;

method in the top level controller in your application and leave that method out of all the child VC's. The children will inherit those supported orientations from the parent.

LJ Wilson
  • 14,445
  • 5
  • 38
  • 62