Xib for different iOS devices/simulator?

吃可爱长大的小学妹 提交于 2019-12-12 10:23:10

问题


I run the simulator, I go to Hardware and Device, it shows list of Devices

iOS Simulator > Hardware > Device


iPad
iPad (Retina)

iPhone
iPhone (Retina 3.5 inch)
iPhone (Retina 4 inch)

I want to make different XIBs for all these devices. But I want to know the way. as I see there are two options in Xib Attribute Inspector

Xib Attribute Inspector > Size

Freeform
Retina 3.5 Full Screen
Retina 4 Full Screen

Though there

iPhone/iPod Touch 320x480
iPhone/iPod Touch having retina display 640x960
iPhone/iPod touch 5th 640x1136
iPad with non retina display 768x1024
iPad With retina display 1536x2048
iPad mini 768x1024

` How should I handle Xibs for above given Devices shown in simulator and how it covers all the iOS devices?


回答1:


You can get right tutorial for autoresizing here.

Just keep only two xib's

1) For iPhone that should be of size 320x480(3.5) OR 320x568 (4.0)
2)For iPad that should be of size 768x1024.

Manage Images for iphone and ipad with the same name differentiating it with prefix before extension.

like

image.png for iphone image@2x.png for iphone retina.

Change subViews autoresize as

Check your 3.5 and 4.0 view as




回答2:


Create image.png and image@2x.png in your project. When referencing the image, use image.png. The OS will automatically select the correct image for the display.

To handle iPhone 5 vs iPhone 4, use auto resize, also known as springs and struts. This is what was used to handle dynamic layouts before autolayout came along.

You should only need two xibs by using these methods, one for iPad and one for iPhone.



来源:https://stackoverflow.com/questions/17938427/xib-for-different-ios-devices-simulator

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!