0

I want to use custom splash screen so I am doing this in my app delegate

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

    // Override point for customization after application launch.

    homeNavigationController = [[UINavigationController alloc] init];
    homeNavigationController.navigationBarHidden = NO;

    [homeNavigationController pushViewController:viewController animated:NO];

    // Add the view controller's view to the window and display.
    [window addSubview:homeNavigationController.view];
    [window makeKeyAndVisible];

    [self animateSplash];

    return YES;
}

- (void)animateSplash {

    CGRect cgRect = [[UIScreen mainScreen] bounds];
    CGSize cgSize = cgRect.size;

    // set default portrait for now, will be updated if necessary
    NSString *imageName = @"splash_screen.png";
    CGRect imageFrame = CGRectMake( 0, 0, cgSize.width, cgSize.height );

    imageStage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
    imageStage.frame = imageFrame;


    [window addSubview:imageStage];
    [window bringSubviewToFront:imageStage];

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDelay:2];
    [UIView setAnimationDuration:3.0f];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];

    imageStage.alpha = 0.0f;

    [UIView commitAnimations];
}

- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {

    // remove and clean up splash image view
    [imageStage removeFromSuperview];
    [imageStage release];
    imageStage = nil;

}

This work ok but as my app is Launches in Landscape (Home button right) mode my splash image orientation is not setting correctly.

a4arpan
  • 1,828
  • 2
  • 24
  • 41
  • 1
    Please read the FAQ before posting; special points of interest for you: 1. code formatting, 2. using footers. – Till Apr 10 '12 at 19:48
  • 1
    Sure will do that Till I am new to StackOverflow :( will take care from the next time. – a4arpan Apr 10 '12 at 19:50

2 Answers2

1

Just use an image that is rotated to look correct in your orientation.

If you really want to do it in code for some reason, check out How to Rotate a UIImage 90 degrees? for different ways to rotate a UIImage.

Community
  • 1
  • 1
Adam Shiemke
  • 3,734
  • 2
  • 22
  • 23
0

You need to tell iOS that you want to launch your app in Landscape mode. You can follow the directions from Apple here to achieve this.

jmstone617
  • 5,707
  • 2
  • 24
  • 26