UIView shows wrong orientation
Everything works ok on simulator , but on the real iphone 3g there is bug. I call Splash Screen twice. First time - ok , second time i see the bug : http://img413.imageshack.us/i/bugicu.png/
How can i fix it ?
@interface iStateGameAppDelegate : NSObject
{
UIWindow* window;
UINavigationController* navigationController;
}
-(void) showSpalshScreen;
-(void) showSwitchViewController;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@end
@implementation iStateGameAppDelegate
@synthesize window;
@synthesize navigationController;
- (BOOL) application:(UIApplication*) application didFinishLaunchingWithOptions:(NSDictionary*) launchOptions
{
[self showSpalshScreen];
[window makeKeyAndVisible];
return YES;
}
-(void) showSpalshScreen
{
SplashScreen* splashScreen = [[[SplashScreen alloc] initWithNibName:@"SplashScreen" bundle:[NSBundle mainBundle]] autorelease];
[window addSubview:[splashScreen view]];
}
-(void) showSwitchViewController
{
SplashScreen* splashScreen = [[[SplashScreen alloc] initWithNibName:@"SplashScreen" bundle:[NSBundle mainBundle]] autorelease];
[window addSubview:[splashScreen view]];
}
- (void) dealloc
{
[navigationController release];
[window release];
[super dealloc];
}
@interface SplashScreen : UIViewController {}
@end
@implementation SplashScreen
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
NSTimer *timer = [[NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(timerFired:) userInfo:nil repeats:NO] retain];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
- (void)timerFired:(NSTimer *)timer
{
[[UIApplication sharedApplication] setStatusBarHidden:FALSE];
iStateGameAppDelegate* app = [UIApplication sharedApplication].delegate;
[app showSwitchViewController];
[[self view] removeFromSuperview];
[timer invalidate];
[timer release];
timer = nil;
}
- (void)dealloc {
[super dealloc];
}
UIInterfaceOrientationLandscapeRight and UIInterfaceOrientationLandscapeLeft . 上一篇: 如何在MainView上添加一个UIView文件作为子视图
下一篇: UIView显示错误的方向
