相关疑难解决方法(0)

[UIScreen mainScreen] .bounds.size在iOS8中是否依赖于方向?

我在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中的临时错误?

orientation uiinterfaceorientation ios uiscreen ios8

184
推荐指数
8
解决办法
8万
查看次数

如何指定iPhone 6/7自定义边对边图像的大小?

假设我想要一个捆绑的图像占用iPhone应用程序中所有可用的屏幕宽度 - 例如横幅.我想创建my_banner.png与宽度320px,my_banner@2x.png与宽度640pxmy_banner@3x.pngiPhone 6加上与宽度1242px.但iPhone 6的分辨率是750×1334像素.仍然@2x与iPhone 4和5 共享后缀,具有640px宽度.

什么是推荐的方式或一个很好的方式来指定已经为优化的图像文件750px的宽度iPhone 6?好像它不能在一个asset catalog?它应该以编程方式完成吗?是否有其他后缀可用于iPhone 6

iPhone 4,5,6屏幕尺寸 (图片摘自http://www.iphoneresolution.com)

iphone cocoa-touch objective-c ios iphone-6

60
推荐指数
1
解决办法
5万
查看次数

iOS 7启动图像(启动画面)淡出

在iOS 7上,启动图像淡出而不是在加载应用程序时立即消失.

是否有任何设置可以阻止此启动图像淡出动画?我需要它立即消失,就像在iOS 6及更早版本中一样.

编辑答案:

是的,可以将启动图像作为UIImageView添加到顶部窗口,并在启动渐变淡化动画后隐藏它.但这会导致0.4秒的延迟,我正试图避免.

animation splash-screen fadeout ios7

39
推荐指数
2
解决办法
8584
查看次数

从xcassets文件获取启动图像的大小不正确

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文件中,我也无法访问原始图像文件,因此自定义解决方案似乎无从谈起.

有谁知道如何解决这个问题?

xcode ios xcasset

6
推荐指数
1
解决办法
6034
查看次数

从xcassets加载UIImage

我正在尝试从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.

objective-c uiimage ios xcasset

4
推荐指数
1
解决办法
6069
查看次数