本文翻译自:How to develop or migrate apps for iPhone 5 screen resolution?

The new iPhone 5 display has a new aspect ratio and a new resolution (640 x 1136 pixels). 新的iPhone 5显示屏具有新的宽高比和新的分辨率(640 x 1136像素)。

What is required to develop new or transition already existing applications to the new screen size? 开发新的或将现有应用程序转换为新的屏幕尺寸需要什么?

What should we keep in mind to make applications "universal" for both the older displays and the new widescreen aspect ratio? 对于旧的显示器和新的宽屏高宽比,我们应该记住什么使应用程序“通用”?


#1楼

参考:https://stackoom.com/question/q0Ya/如何为iPhone-屏幕分辨率开发或迁移应用程序


#2楼

  1. Download and install latest version of Xcode . 下载并安装最新版本的Xcode 。
  2. Set a Launch Screen File for your app (in the general tab of your target settings). 为您的应用设置启动屏幕文件(在目标设置的常规标签中)。 This is how you get to use the full size of any screen, including iPad split view sizes in iOS 9. 这样便可以使用任何屏幕的完整尺寸,包括iOS 9中的iPad拆分视图尺寸。
  3. Test your app, and hopefully do nothing else, since everything should work magically if you had set auto resizing masks properly, or used Auto Layout. 测试您的应用程序,并希望不执行其他任何操作,因为如果您正确设置了自动调整蒙版的大小或使用了“自动布局”,那么一切都将神奇地工作。
  4. If you didn't, adjust your view layouts, preferably with Auto Layout. 如果没有,请调整视图布局,最好使用“自动布局”。
  5. If there is something you have to do for the larger screens specifically, then it looks like you have to check height of [[UIScreen mainScreen] bounds] as there seems to be no specific API for that. 如果您需要为较大的屏幕做一些特定的事情,那么您似乎必须检查[[UIScreen mainScreen] bounds]高度,因为似乎没有特定的API。 As of iOS 8 there are also size classes that abstract screen sizes into regular or compact vertically and horizontally and are recommended way to adapt your UI. 从iOS 8开始,还有一些尺寸类,它们可以将屏幕尺寸抽象为垂直或水平方向上的紧凑或紧凑,并且是适应UI的推荐方式。

#3楼

The only really required thing to do is to add a launch image named "Default-568h@2x.png" to the app resources, and in general case (if you're lucky enough) the app will work correctly. 唯一真正需要做的是将名为“ Default-568h@2x.png”的启动图像添加到应用程序资源,并且在通常情况下(如果足够幸运的话),该应用程序将正常运行。

In case the app does not handle touch events, then make sure that the key window has the proper size. 如果应用程序无法处理触摸事件,请确保按键窗口的大小正确。 The workaround is to set the proper frame: 解决方法是设置适当的框架:

[window setFrame:[[UIScreen mainScreen] bounds]]

There are other issues not related to screen size when migrating to iOS 6. Read iOS 6.0 Release Notes for details. 迁移到iOS 6时,还有其他与屏幕尺寸无关的问题。有关详细信息,请参阅iOS 6.0发行说明 。


#4楼

Here you can find a nice tutorial (for MonoTouch, but you can use the information for Non-MonoTouch-projects, too): 在这里,您可以找到一个不错的教程(用于MonoTouch,但是您也可以将信息用于Non-MonoTouch项目):
http://redth.info/get-your-monotouch-apps-ready-for-iphone-5-ios-6-today/ http://redth.info/get-your-monotouch-apps-ready-for-iphone-5-ios-6-today/

  1. Create a new image for your splash/default screen ( 640 x 1136 pixel ) with the name " Default-568h@2x.png " 为初始屏幕/默认屏幕( 640 x 1136像素 )创建一个新图像,名称为“ Default-568h@2x.png

  2. In the iOS Simulator , go to the Hardware -> Device menu, and select " iPhone (Retina 4-inch) " iOS模拟器中 ,转到“硬件”->“设备”菜单,然后选择“ iPhone(4英寸视网膜)

  3. Create other images, eg background images 创建其他图像,例如背景图像

  4. Detect iPhone 5 to load your new images: 检测iPhone 5以加载新图像:

public static bool IsTall
{get {return UIDevice.currentDevice.userInterfaceIdiom== UIUserInterfaceIdiomPhone&& UIScreen.mainScreen.bounds.size.height* UIScreen.mainScreen.scale >= 1136;}
}

private static string tallMagic = "-568h@2x";
public static UIImage FromBundle16x9(string path)
{//adopt the -568h@2x naming conventionif(IsTall()){var imagePath = Path.GetDirectoryName(path.ToString());var imageFile = Path.GetFileNameWithoutExtension(path.ToString());var imageExt = Path.GetExtension(path.ToString());imageFile = imageFile + tallMagic + imageExt;return UIImage.FromFile(Path.Combine(imagePath,imageFile));}else{return UIImage.FromBundle(path.ToString());}
}

#5楼

If you have an app built for iPhone 4S or earlier, it'll run letterboxed on iPhone 5. 如果您有为iPhone 4S或更早版本构建的应用程序,它将在iPhone 5上运行带信箱功能的应用程序。

To adapt your app to the new taller screen, the first thing you do is to change the launch image to: Default-568h@2x.png. 为了使您的应用适应更高的新屏幕,您要做的第一件事是将启动图像更改为:Default-568h@2x.png。 Its size should be 1136x640 (HxW). 其大小应为1136x640(HxW)。 Yep, having the default image in the new screen size is the key to let your app take the whole of new iPhone 5's screen . 是的,在新的屏幕尺寸中具有默认图像是使您的应用占据新iPhone 5整个屏幕的关键

(Note that the naming convention works only for the default image. Naming another image "Image-568h@2x.png" will not cause it to be loaded in place of "Image@2x.png". If you need to load different images for different screen sizes, you'll have to do it programmatically.) (请注意,命名约定仅适用于默认图像。将另一个图像命名为“ Image-568h@2x.png”不会导致将其替换为“ Image@2x.png”。如果需要加载其他图像对于不同的屏幕尺寸,您必须以编程方式进行操作。)

If you're very very lucky, that might be it... but in all likelihood, you'll have to take a few more steps. 如果您非常幸运,也许就是这样...但是很可能, 您将不得不采取更多步骤。

  • Make sure, your Xibs/Views use auto-layout to resize themselves. 确保您的Xib / View使用自动布局来调整自身大小。
  • Use springs and struts to resize views. 使用弹簧和支柱调整视图大小。
  • If this is not good enough for your app, design your xib/storyboard for one specific screen size and reposition programmatically for the other. 如果这对您的应用程序还不够好,请为一种特定的屏幕尺寸设计xib / storyboard,然后针对另一种尺寸以编程方式重新定位。

In the extreme case (when none of the above suffices), design the two Xibs and load the appropriate one in the view controller. 在极端情况下(当以上条件都不满足时),设计两个Xib,然后在视图控制器中加载适当的一个。

To detect screen size: 要检测屏幕尺寸:

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{CGSize result = [[UIScreen mainScreen] bounds].size;if(result.height == 480){// iPhone Classic}if(result.height == 568){// iPhone 5}
}

#6楼

You could add this code: 您可以添加以下代码:

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) {CGSize result = [[UIScreen mainScreen] bounds].size;CGFloat scale = [UIScreen mainScreen].scale;result = CGSizeMake(result.width * scale, result.height * scale);if(result.height == 960) {NSLog(@"iPhone 4 Resolution");}if(result.height == 1136) {NSLog(@"iPhone 5 Resolution");}}else{NSLog(@"Standard Resolution");}}

如何为iPhone 5屏幕分辨率开发或迁移应用程序?相关推荐

  1. ipad与iphone的屏幕分辨率

    1.ipad分辨率,iphone 6 iPhone设备      尺寸 分辨率                   点 iPhone 3和3s  3.5英寸    (320×480)          ...

  2. android 主流分辨率是多少,android 屏幕分辨率问题

    iPhone的icon设计就这么简单,iPhone的屏幕只有320×480像素,所以程序没有适配性问题. Android 在研究Android的icon设计之前,有必要先了解Android的界面是如何 ...

  3. iPhone X(10)屏幕分辨率与适配

    iPhone X(10)屏幕分辨率与适配,iOS开发适配与UI设计问题.iPhone人机交互指南. 北京时间的9月13日凌晨,美国当地时间的9月12日上午,苹果在发布会上发布了四款产品,本包括全新的A ...

  4. iPhone 6屏幕:4.7英寸1334*750分辨率,5.5英寸1920*1080,UI适配不困难

    苹果iPhone 6应该会配置4.7英寸屏幕,显示分辨率为1334*750.换句话说,尽管iPhone 6的屏幕像素密度与iPhone 5S相同为326ppi,不过因为分辨率的高宽都发生了变化,手机应 ...

  5. iphone各个型号屏幕分辨率总结

    原文地址::https://blog.csdn.net/amyloverice/article/details/79389357 iPhone: iPhone 1G 320x480 iPhone 3G ...

  6. 安卓开发屏幕分辨率尺寸适配问题【原创】

    2019独角兽企业重金招聘Python工程师标准>>> 屏幕分辨率尺寸适配是安卓开发中的难题之一,我开发中的解决办法是: 1.多使用相对布局,即RelativeLayout,或者Li ...

  7. Android开发笔记(三)屏幕分辨率

    在app编码中经常需要获取手机的屏幕分辨率(宽*高),原来我直接上网拷贝代码,但在使用过程中却发现诸多不便. 不便一:下面代码中的getWidth和getHeight在adt上提示deprecated ...

  8. 一张图帮你看懂 iPhone 6 Plus 的屏幕分辨率

    一张图帮你看懂 iPhone 6 Plus 的屏幕分辨率 几天前发布的 iPhone 6 Plus 官方标称屏幕是 1920 x 1080 的,但是在 Xcode 中我们发现模拟器的屏幕其实是看似奇怪 ...

  9. H5网页开发新手入门-H5网页如何适应不同手机屏幕分辨率?

    一.问题汇总 手机网页怎么制作? 怎么让网页适应不同手机屏幕? H5网页设计到底该设计多大尺寸? rem怎么自适应布局? H5一屛页面如何自适应屏幕? viewport该怎么写? width=devi ...

最新文章

  1. 大数据项目产品选型的五个建议
  2. github标星11600+:最全的吴恩达机器学习课程资源(完整笔记、中英文字幕视频、python作业,提供百度云镜像!)...
  3. 单元测试Struts2Spring项目的Action和Service(包含源码)
  4. sqlserver 库服务器导数据
  5. 华为在 5G 初期不考虑盈利;​网易发布数据中台;微软 SQL Server 2019 免费支持 Java | 极客头条...
  6. python递归查找值返回_python – 从树递归中返回值列表
  7. 如何让ul的符号隐藏_亚马逊关键词大师,那些你不知道的隐藏keywords操作方法(干货)...
  8. C语言——简单三子棋
  9. 干细胞体外培养最新技术进展(2021年9月)
  10. 每日一面 - 为何hashmap默认的负载因子是0.75?应该是空间和时间的折中,背后的统计原理是什么呢?
  11. 哈利波特AR游戏-巫师联盟 深度解析
  12. 三问中国电子云,此时入局的深意是什么?
  13. 哈尔滨理工大学第七届程序设计竞赛决赛(网络赛-高年级组)G - 幼儿园战争...
  14. MySQL数据库课程设计_什么是数据库?如何学习数据库?
  15. shineblink HC-SR505人体红外感应传感器
  16. 观点:开放式元宇宙将释放每个人的创造力
  17. ASP.NET Core 托管和部署(一)【Kestrel】
  18. 【C/C++】用格雷戈里公式求π
  19. 中文网页的外链对Google谷歌SEO有用吗
  20. 逆序链表从m到n位置

热门文章

  1. Android获取SharedPreferences失败,且App无法启动
  2. 浅谈缓冲区溢出之栈溢出上
  3. CentOS linux修改主机名
  4. 八、IO优化(3)稀疏列
  5. centosx64 6.2安装virtualbox
  6. [转载] New Concept English 1——Lesson 8 What's your job?
  7. 時間用function 來計算...如此精確.
  8. input type=file图片上传时,先预览
  9. js 读取外部的本地json文件
  10. Oracle DBHelper