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

chbeer

macrumors member
Sep 22, 2008
82
0
Berlin
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).
 

RexInTheCity

macrumors newbie
Original poster
Jun 9, 2008
17
0
chbeer, you are right about the app not rotating at all.

This is the only code I have done so far.

Code:
#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

Code:
#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

Code:
#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

macrumors regular
Dec 25, 2008
164
0
Vancouver, BC, Canada
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:

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:

Code:
    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

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
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...
 

North Bronson

macrumors 6502
Oct 31, 2007
395
1
San José
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

macrumors newbie
Original poster
Jun 9, 2008
17
0
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?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.