PDA

View Full Version : TabBar Won't Rotate




RexInTheCity
Feb 26, 2009, 03:07 PM
I followed these instructions to make the app open in landscape mode, http://dejoware.com/blogpages/files/iphone_programming_landscape_view_tutorial.html

http://img515.imageshack.us/img515/8528/picture2a.png (http://imageshack.us)
http://img515.imageshack.us/img515/picture2a.png/1/w484.png (http://g.imageshack.us/img515/picture2a.png/1/)

http://img22.imageshack.us/img22/5946/picture3x.png (http://imageshack.us)
http://img22.imageshack.us/img22/picture3x.png/1/w698.png (http://g.imageshack.us/img22/picture3x.png/1/)

But as you can see the tab bar does not want to rotate into landscape mode. Does anyone know how to solve this issue?



chbeer
Feb 27, 2009, 07:45 AM
Are you sure your app was realy rotated? maybe add an image or something to see, if the content of the view realy get's rotated.

My idea would be that you prevent your view from getting rotated. (there is a method for that, I can't remember the name and don't have access to the documentation).

dejo
Feb 27, 2009, 09:58 AM
Sounds like I may need to do a follow-up tutorial... :D

RexInTheCity
Feb 27, 2009, 12:14 PM
chbeer, you are right about the app not rotating at all.

This is the only code I have done so far.


#import <UIKit/UIKit.h>

@class ViewController;

@interface AppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIWindow *window;
IBOutlet UITabBarController *rootController;
}

@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) UITabBarController *rootController;

@end


#import "AppDelegate.h"

@implementation AppDelegate

@synthesize window;
@synthesize rootController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:rootController.view];
[window makeKeyAndVisible];

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
}


- (void)dealloc {
[rootController release];
[window release];
[super dealloc];
}

@end


#import "ViewController.h"


@implementation ViewController

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}


- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}


- (void)dealloc {
[super dealloc];
}

@end

LTX
Feb 27, 2009, 03:26 PM
I am brand new to iPhone programming, but I've done a few apps from my book, so I may know how to fix it. From what I can tell, it looks like you aren't supporting the landscape left orientation, as in the following code:


@implementation ViewController

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}


Try changing the last line to the following, or simply rotating the simulator the other way:


return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);


Or I could be completely wrong.

If that doesn't work, I'll be back in a bit, and I'll see what the book had to say about the rotating view app.

dejo
Feb 27, 2009, 04:45 PM
Yeah, RexInTheCity, if you didn't change shouldAutorotateToInterfaceOrientation:, you haven't followed my entire tutorial. :)

EDIT: OK, Tab Bar apps are trickier. They doesn't seem to respond to the techniques from my tutorial. I'm still looking into it...

RexInTheCity
Feb 27, 2009, 08:28 PM
Adding left doesn't change anything and I only want it on LandscapeRight anyways.

RexInTheCity
Mar 3, 2009, 07:36 PM
Dejo, I don't suppose you've found anything? I still haven't gotten anywhere

dejo
Mar 3, 2009, 08:00 PM
Dejo, I don't suppose you've found anything? I still haven't gotten anywhere
All I found was this: Auto-rotating Tab Bars on the iPhone (http://blog.costan.us/2009/01/auto-rotating-tab-bars-on-iphone.html)

Haven't had a chance to check it out yet.

North Bronson
Mar 4, 2009, 01:37 PM
For what it's worth, I made a Custom Tab Bar Controller class (CustomTabBarController), over-rode shouldAutorotateToInterfaceOrientation for this class, and it worked.

The documentation says that Tab Bar Controller is not meant to be subclassed; so I guess it's not entirely Kosher.

RexInTheCity
Mar 6, 2009, 01:55 AM
For what it's worth, I made a Custom Tab Bar Controller class (CustomTabBarController), over-rode shouldAutorotateToInterfaceOrientation for this class, and it worked.

The documentation says that Tab Bar Controller is not meant to be subclassed; so I guess it's not entirely Kosher.

Thanks Bruin, it worked perfectly.

Does anyone know of any side effects of subclassing a tab bar controller since Apple doesn't suggest it?

North Bronson
Mar 6, 2009, 04:39 PM
Does anyone know of any side effects of subclassing a tab bar controller since Apple doesn't suggest it?

Goons. Hired goons. :p