Beginner’s Titanium: Titanium DisplayCaps on iOS

There are now a multitude of device resolutions and densities running iOS, how can you make sure your content appears how you want it to appear regardless of which device your users have? This is, of course, one of the trickier areas for mobile applications. Fortunately, Titanium Studio has tools to help us attack this problem. Initially I thought that the DisplayCaps properties I could access through the Titanium API would produce the exact pixel dimensions of the device my App was running on. Upon a more careful inspection of the Titanium documentation these properties will produce values of “density-independent pixels (dip) on iOS”. I went ahead and ran a few tests on the simulator to determine what values I would receive on each device:

[cc]
Ti.API.info(“height: ” + Ti.Platform.displayCaps.platformHeight);
Ti.API.info(“width: ” + Ti.Platform.displayCaps.platformWidth);
[/cc]

iPad (non-retina): height: 1024 width: 768
iPad (retina): height: 1024 width: 768
iPhone (non-retina): height: 480 width: 320
iPhone (3.5 inch retina): height: 480 width: 320
iPhone (4 inch retina): height: 568 width: 320

Also keep in mind that the values are relative the the orientation of the UI (not necessarily the physical orientation of the device). Another useful property of Ti.Platform is the dpi property which can provide useful information about whether the device has a retina display or not. This information helped clear up some issues for me and enabled me to better plan layouts for multiple devices, I hope the information was helpful for your App Development as well!

Edwin

Edwin

December 11, 2012

More like this delivered right to you:

Sign up for our Newsletter to get our latest posts plus invitations to our events and access to future whitepapers.

Related Posts

7 Tips for Utilizing Amazon Alexa to Engage with Customers

7 Tips for Utilizing Amazon Alexa to Engage with Customers

Amazon first released Alexa virtual assistant and smart speaker Echo in late 2014. An in-home virtual assistant is an impressive tool, but creating a seamless user experience with it can be a challenge. So how do companies overcome this challenge? What engagement can...

How to Engage Customers With QR Codes and Augmented Reality

How to Engage Customers With QR Codes and Augmented Reality

When one of our clients approached us with the idea of building an entirely new customer engagement app for their grocery stores, we were very excited. Their goal was to build a mobile application that customers could use to learn about products, find them in the...

Ready to drop us a line?