iPhone Application: force landscape mode, strange behaviour...?
Posted
by David Lawson
on Stack Overflow
See other posts from Stack Overflow
or by David Lawson
Published on 2010-06-15T20:58:47Z
Indexed on
2010/06/15
21:02 UTC
Read the original article
Hit count: 246
iphone-sdk
|xcode
This is a method I use to switch display views, based on a string passed (for example you could pass MainMenuViewController to switch views to a new instance of that class):
- (void)displayView:(NSString *)newView
{
NSLog(@"%@", newView);
[[currentView view] removeFromSuperview];
[currentView release];
UIViewController *newView = [[NSClassFromString(newView) alloc] init];
[[newView view] setFrame:CGRectMake(0, 0, 320, 460)];
[self setCurrentView:newView];
[[self view] addSubview:[currentView view]];
}
I have my application forced into landscape view (.plist and -shouldRotate), but if you look in the code:
[[newView view] setFrame:CGRectMake(0, 0, 320, 460)];
I have to set the frame of the newView to a portrait frame for the view to be displayed correctly - otherwise, for example, a button on the new view can only be pressed in certain parts of the screen (rectangle up the top), unresponsive anywhere else. Even though in all my NIB files they are set to landscape.
© Stack Overflow or respective owner