2010-12-19 47 views
1

在模擬器上一切正常,但在真正的iPhone 3G上有錯誤。 我打電話閃屏兩次。第一次 - 好吧,第二次我看到的錯誤:http://img413.imageshack.us/i/bugicu.png/UIView顯示錯誤的方向

我該如何解決它?

 
@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]; 
} 

回答

0
  1. 確保視圖的委託是否設置正確。
  2. 您應該檢查UIInterfaceOrientationLandscapeRightUIInterfaceOrientationLandscapeLeft