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

kloveridge6502

macrumors newbie
Original poster
Dec 8, 2010
1
0
I am developing a iPad app and have run into a snag that I'm hoping someone out there could help me with.

My game is designed to run in Portrait mode. Apple requires an iPad app to run in both Portrait and Landscape mode. To support landscape, I allow my app to rotate and letterbox. So to be clear, when in landscape mode, the game shrinks black space to the left and right of the game.

Visually I've got this working perfectly. But for some reason (and this is my question), the touch controls seem to have locked themselves into landscape mode. So in other words, when the game is in portrait mode, touch doesn't respond in the regions where the letterbox would be seen in landscape mode. I can't figure out how to fix this!

Here's the skeletal code of what I'm doing (I've eliminated non-related code):

in main.cpp:
int retVal = UIApplicationMain(argc, argv, nil, @"derbyPoker_ipadAppDelegate");


in the delegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

window = [[ UIWindow alloc ] initWithFrame:[[UIScreen mainScreen] bounds]];
viewController = [ glView new ];

viewController.view = [[game alloc] initWithFrame:CGRectMake(0, 0, 768, 1024) andManager:self];
viewController.view.contentMode = UIViewContentModeScaleAspectFit;
viewController.view.autoresizesSubviews = YES;
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}

The culprit seems to be related to viewController.view.contentMode = UIViewContentModeScaleAspectFit;

If I eliminate that line, the portrait mode touch works fine. But then when I'm landscape, the game stretches. This won't work either.

I'd welcome and response from someone out there with some experience with this.
Thanks in advance.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.