开发者

inches between points iPhone

I need to calculate the distance, in inches, between two touches on any iOS device.

Is there a way to get convert pixels to inches in the iOS sdk?

This needs to work if you install it on any device and even if you install an iPhone app on an iPad and hit th开发者_如何学JAVAe 2x button.

Is this possible?


You'll have to figure out the PPI(pixels per inch) of the display, with that you can convert pixels to inches. However I haven't found any way to get those values programmatically. I think you should hard code it and determine on which device you are to decide which PPI value to use. This is not future save however.

To determine the distance in pixels between two touches refer to How exactly do I output the distance between two touch points in Xcode for iOS?.

Detect Retina Display will tell you if you are on an iPhone4.

Have a look at Erica Sadun's uidevice-extension lib.

List of displays by pixel density at wikipedia.org.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜