我有一个通用的应用程序。在此应用程序中,我将介绍图像设置为启动画面。对于 iPhone,我需要设置不同的图像作为启动屏幕,而对于 iPad,我需要设置不同的图像。当我使用下面的代码时,它适用于 iphone 但不适用于 ipad。这是我的代码。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self copyDatabaseIfNeeded];
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
splashViewBg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 1004)];
splashViewBg.image = [UIImage imageNamed:@"jamil.png"];
//splashViewBg.contentMode = UIViewContentModeScaleAspectFill;
[window addSubview:splashViewBg];
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 1004)];
splashView.image = [UIImage imageNamed:@"jamil.png"];
//splashView.contentMode = UIViewContentModeScaleAspectFill;
splashView.alpha = 0.0f;
}
else
{
splashViewBg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashViewBg.image = [UIImage imageNamed:@"defualt.png"];
//splashViewBg.contentMode = UIViewContentModeScaleAspectFill;
[window addSubview:splashViewBg];
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashView.image = [UIImage imageNamed:@"defualt.png"];
//splashView.contentMode = UIViewContentModeScaleAspectFill;
splashView.alpha = 0.0f;
}
[UIView beginAnimations:@"show" context:NULL];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
splashView.alpha = 1.0f;
[UIView commitAnimations];
[self performSelector:@selector(removeSplash) withObject:nil afterDelay:2.0];
[self performSelector:@selector(removeSplashBg) withObject:nil afterDelay:3.5];
return YES;
}
- (void) removeSplash {
[UIView beginAnimations:@"hide" context:NULL];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
splashView.alpha = 0.0f;
[UIView commitAnimations];
}
- (void) removeSplashBg {
[splashView removeFromSuperview];
[splashViewBg removeFromSuperview];
}