iphoneDeviceModel lookup library

Mark Smith marksmithhfx at gmail.com
Sun Oct 3 14:44:24 EDT 2021

Thanks Andreas. Looking forward to trying it out.


Sent from my iPhone

> On Oct 3, 2021, at 11:44 AM, Andreas Bergendal via use-livecode <use-livecode at lists.runrev.com> wrote:
> Hi guys,
> This is for those of you who develop for iOS. We all know the challenge of getting the layout right for various iOS screens. ”The notch” (camera area at the top) is especially annoying, since there’s no easy way of knowing if the user’s device has one or not, and how many pixels it is (there are 4 variants!).
> In LC 9.6.3 iphoneDeviceModel was introduced. Where machine() just returns ”iphone”, iphoneDeviceModel() returns e.g. ”iPhone10,6” (=iPhone X) or ”iPad13,7” (=iPad Pro 11 inch).
> But the Dictionary entry on iphoneDeviceModel just links to a Wikipedia page listing mammoth tables of Apple device data. There is no way of knowing what ”iPhone10,6” means without a decent lookup table.
> So, I’ve made one! And a library to use it with! And a demo stack to test it with!
> It will check the device code of the current device, and return an array with values for:
> - notch margin
> - portrait bottom margin
> - landscape bottom margin
> - (device model name - in the rare case that you'd need it)
> You use these for determining the safe area your UI elements can use, when rearranging them in response to the resizeStack message.
> Or e.g. how much taller the Header bar widget needs to be on a ”notch” device in order to look good.
> It’s all here and free to get, use and modify as you need:
> https://github.com/wheninspace/WISmobDeviceLib <https://github.com/wheninspace/WISmobDeviceLib>
> The demo stack has the library in its stack script, and the full lookup array in a cProp, so that stack is all you need really.
> Testing must be done by deploying to physical devices though, as iphoneDeviceModel() does not work in the iOS Simulator (or, it works, but just returns a code for the Simulator itself…).
> Let me know if anything can be improved on (of course it can)! :)
> The source for my data is this excellent website:
> https://www.screensizes.app/ <https://www.screensizes.app/> which has comprehensive screen info on every existing iOS device since the first iPhone.
> And this list which has the device codes interpreted:
> https://gist.github.com/adamawolf/3048717#file-apple_mobile_device_types-txt <https://gist.github.com/adamawolf/3048717#file-apple_mobile_device_types-txt>
> Cheers,
> Andreas
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

More information about the use-livecode mailing list