我在iOS 7和iOS 8中运行了以下代码:
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landscape = (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight);
NSLog(@"Currently landscape: %@, width: %.2f, height: %.2f",
(landscape ? @"Yes" : @"No"),
[[UIScreen mainScreen] bounds].size.width,
[[UIScreen mainScreen] bounds].size.height);
Run Code Online (Sandbox Code Playgroud)
以下是iOS 8的结果:
Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 568.00, height: 320.00
Run Code Online (Sandbox Code Playgroud)
与iOS 7中的结果相比:
Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 320.00, height: 568.00
Run Code Online (Sandbox Code Playgroud)
是否有任何文件指定此更改?或者它是iOS 8 API中的临时错误?
假设我想要一个捆绑的图像占用iPhone应用程序中所有可用的屏幕宽度 - 例如横幅.我想创建my_banner.png与宽度320px,my_banner@2x.png与宽度640px和my_banner@3x.png为iPhone 6加上与宽度1242px.但iPhone 6的分辨率是750×1334像素.仍然@2x与iPhone 4和5 共享后缀,具有640px宽度.
什么是推荐的方式或一个很好的方式来指定已经为优化的图像文件750px的宽度iPhone 6?好像它不能在一个asset catalog?它应该以编程方式完成吗?是否有其他后缀可用于iPhone 6?
在iOS 7上,启动图像淡出而不是在加载应用程序时立即消失.
是否有任何设置可以阻止此启动图像淡出动画?我需要它立即消失,就像在iOS 6及更早版本中一样.
编辑答案:
是的,可以将启动图像作为UIImageView添加到顶部窗口,并在启动渐变淡化动画后隐藏它.但这会导致0.4秒的延迟,我正试图避免.
Xcode的默认Images.xcassets文件有一个插槽LaunchImage,对于一个纵向iPhone应用程序,有5个可能的插槽.
根据文档,要从xcassets文件中获取正确大小的图像,只需使用[UIImage imageNamed:].
但是,在iPhone Retine(4英寸)模拟器上运行以下代码:
UIImage *splashImage = [UIImage imageNamed:@"LaunchImage"];
NSLog(@"%@", NSStringFromCGSize(splashImage.size));
Run Code Online (Sandbox Code Playgroud)
产生以下输出:
{320, 480}
Run Code Online (Sandbox Code Playgroud)
这显然是错误的大小.
我确保xcassets文件中的映射是正确的,并确认了所有维度.我似乎无法从xcassets文件中的给定集合请求特定图像,这意味着我无法做到:[UIImage imageNamed:@"LaunchImageR4"].
由于文件被添加到xcassets文件中,我也无法访问原始图像文件,因此自定义解决方案似乎无从谈起.
有谁知道如何解决这个问题?
我正在尝试从Image.xcassets文件夹加载启动图像,但无济于事.在SO上有其他答案(和这一个)旨在回答它但是它们的主要解决方案,简单地加载像这样的图像
UIImage *image = [UIImage imageNamed:@"Default@2x"];
Run Code Online (Sandbox Code Playgroud)
为我回报为零.
文件名正确命名,项目设置为使用资产.
有谁知道我是怎么做的,或者我做错了什么?
提前致谢.
编辑:
编辑2:我的最终代码:
-(void) loadSplashImage{
if ([self isiPad]){
self.imageViewSplash.image = [UIImage imageNamed:@"Default-Portrait"];
}
else{
if (self.view.frame.size.height == 480){
self.imageViewSplash.image = [UIImage imageNamed:@"Default"];
}
else if (self.view.frame.size.height == 568){
self.imageViewSplash.image = [UIImage imageNamed:@"Default-568h"];
}
else if (self.view.frame.size.height == 667){
self.imageViewSplash.image = [UIImage imageNamed:@"Default-667h"];
}
}
Run Code Online (Sandbox Code Playgroud)
}
请注意它仅适用于Portrait.
ios ×4
objective-c ×2
xcasset ×2
animation ×1
cocoa-touch ×1
fadeout ×1
ios7 ×1
ios8 ×1
iphone ×1
iphone-6 ×1
orientation ×1
uiimage ×1
uiscreen ×1
xcode ×1