1
votes

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

1 Answers

0
votes
  1. Make sure the view's delegate is correctly set.
  2. You should probably check for both UIInterfaceOrientationLandscapeRight and UIInterfaceOrientationLandscapeLeft.