我有一个通用应用程序。我在项目中添加了启动图像。
我想等待启动画面直到从webservice下载json。我的应用程序正在等待下载json。但启动图像选择不正确或位置。我写了下面的代码。例如:我的启动图像正确在iPhone 5上。但不是在iphone 3gs上。
我怎么能轻易做到这一点?对不起我的英文。谢谢。
CGRect screenRect = [[UIScreen mainScreen] bounds];
float screenWidth = screenRect.size.width;
float screenHeight = screenRect.size.height;
splashView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
float sysVer = [[[UIDevice currentDevice] systemVersion] floatValue];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
NSLog(@"height %f version %f",[[UIScreen mainScreen] bounds].size.height,sysVer);
if (sysVer <7.0)
{
// iOS-6.01 and prior code
if (screenHeight==480)
{
splashView.image=[UIImage imageNamed:@"Default"];//iPhone
}
else if (screenHeight == 568.0f)
{
splashView.image=[UIImage imageNamed:@"Default-568h@2x.png"];
}
}
else // for ios7
{
if (!screenHeight == 568.0f)
{
splashView.image=[UIImage imageNamed:@"Default"];//iPhone
}
else
{
splashView.image=[UIImage imageNamed:@"Default-568h@2x.png"];
}
}
}
else
{
if (sysVer <=6.1)
{
splashView.image=[UIImage imageNamed:@"Default-Portrait"];// iPads
}
else
{
splashView.image=[UIImage imageNamed:@"Default-7681024"];// iPads
}
}
[self.view addSubview:splashView];
日志在iphone 3gs上
height 480.000000 version 6.100000