Reputation: 1981
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.
Upvotes: 0
Views: 673
Reputation: 5707
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.
Upvotes: 0
Reputation: 3742
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.
Upvotes: 1