Thursday, September 23, 2010

Window height in Titanium/iPhone

Just a caution: while using Appcelerator Titanium, we aware that Titanium.Platform.displayCaps.platformHeight includes the iPhone status bar height -- which is essentially unusable real estate since it always shows in an application. So you have to deduct 20 to get the actual usable space on an iPhone.

For instance:

I created a buttonbar (with a height of 50) and wanted position it at the bottom of the screen. So I thought that the easiest way would be to use the Titanium.Platform.displayCaps.platformHeight as my layout height and then just set the buttonbar to have a top value of Titanium.Platform.displayCaps.platformHeight - myButtonBar.height.

However, this always placed the buttonbar too low on the screen. It was only when I modified the variable to account for the 20 pixel status bar did everything line up properly:

Titanium.Platform.displayCaps.platformHeight - myButtonBar.height - 20

No comments: