Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

primedime

macrumors member
Original poster
Mar 21, 2011
66
0
Ft. Lauderdale, FL
Ok, I have a view that basically is a UIWebView that pulls up the mobile youtube site. Everything works perfectly but when I play the videos they only show in Portrait and don't allow me to turn it sideways to get a Landscape look so that the video takes up the screen.

Now I have tried all of the orientation codes but when I apply them it causes my application to hang at the splash screen... is there something else I should be setting besides just adding this code? Also, the youtube view of my app is not the first view that shows when the app launches.

Code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    // Return YES for supported orientations

    return YES;

}

I looked in IB and didn't really see anything that gives the view authority to switch orientation. I only see the option to make it Portrait or Landscape.
 

ashwinr87

macrumors member
Mar 9, 2011
81
0
Check if this works...

Code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	
	return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
 

primedime

macrumors member
Original poster
Mar 21, 2011
66
0
Ft. Lauderdale, FL
Nope, didn't work either. I have a tab bar and toolbar on this view, does that have any effect on this working or not?

Here is the full code for the view:

Code:
#import "YoutubeViewController.h"
@implementation YoutubeViewController
@synthesize myWebView;
@synthesize spinnerView;
@synthesize toolbar;

- (void)loadWebPageWithString:(NSString *)urlString
{
	NSURL *url = [NSURL URLWithString:urlString];
	NSURLRequest *request = [NSURLRequest requestWithURL:url];
	[myWebView loadRequest:request];
}

-(IBAction)stopLoading
{
	NSLog(@"stopLoading");
}
-(IBAction)goHome 
{
    NSString *urlAddress = @"http://www.m.youtube.com/saleshuddle";
    
    NSURL *address = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:address];
    [myWebView loadRequest:requestObj];
}
-(IBAction)reload
{
	NSLog(@"reload");
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewWillDisappear:(BOOL)animated
{
	[myWebView stopLoading];
}

- (void)dealloc
{
    [myWebView release];
	[spinnerView release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
	
	[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.m.youtube.com/saleshuddle"]]];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	
	return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

#pragma mark -
#pragma mark UIWebViewDelegate methods

- (void)webViewDidStartLoad:(UIWebView *)myWebView
{
	[spinnerView startAnimating];
}

- (void)webViewDidFinishLoad:(UIWebView *)myWebView
{
	[spinnerView stopAnimating];
}
@end
 

ashwinr87

macrumors member
Mar 9, 2011
81
0
sorry I forgot to mention one more thing as well.. you got to do one change in the plist file..

In the plist file, add a new row at the end and in the "information Property list" type in "Initial Interface Orientation" and in the "value" type in "Landscape(right home button)"

Those are the changes I did...
and no having a tab bar and a toolbar should not affect it as far as I know but I may be wrong...

Nope, didn't work either. I have a tab bar and toolbar on this view, does that have any effect on this working or not?

Here is the full code for the view:

Code:
#import "YoutubeViewController.h"
@implementation YoutubeViewController
@synthesize myWebView;
@synthesize spinnerView;
@synthesize toolbar;

- (void)loadWebPageWithString:(NSString *)urlString
{
	NSURL *url = [NSURL URLWithString:urlString];
	NSURLRequest *request = [NSURLRequest requestWithURL:url];
	[myWebView loadRequest:request];
}

-(IBAction)stopLoading
{
	NSLog(@"stopLoading");
}
-(IBAction)goHome 
{
    NSString *urlAddress = @"http://www.m.youtube.com/saleshuddle";
    
    NSURL *address = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:address];
    [myWebView loadRequest:requestObj];
}
-(IBAction)reload
{
	NSLog(@"reload");
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewWillDisappear:(BOOL)animated
{
	[myWebView stopLoading];
}

- (void)dealloc
{
    [myWebView release];
	[spinnerView release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
	
	[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.m.youtube.com/saleshuddle"]]];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	
	return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

#pragma mark -
#pragma mark UIWebViewDelegate methods

- (void)webViewDidStartLoad:(UIWebView *)myWebView
{
	[spinnerView startAnimating];
}

- (void)webViewDidFinishLoad:(UIWebView *)myWebView
{
	[spinnerView stopAnimating];
}
@end
 

primedime

macrumors member
Original poster
Mar 21, 2011
66
0
Ft. Lauderdale, FL
No, that didn't work either. Also, I don't need my initial view to be able to change orientation i just need one of my subviews to be able to, specifically my view that has a UIWebView showing the mobile youtube page.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.