Coding around the differences between the iOS and Android APIs
Although Appcelerator Titanium makes much of the hard work of integrating numerous operating systems and devices invisible to you, the developer, there are going to be times when you simply have to write some code that is platform-specific. The most common way of doing this is by checking the osname
property from the Ti.Platform
namespace.
In this recipe, we will create a simple screen that shows a custom activity indicator when the device is an iPhone, and a standard indicator when the user is using an Android device.
Again, the complete source code for this recipe can be found in the /Chapter 11/Recipe 4
folder.
How to do it…
Open your app.js
file, remove any existing code, and type the following:
// create root window var win1 = Ti.UI.createWindow({ title: 'Tab 1', backgroundColor: '#fff' }); ///this next bit is a custom activity indicator for iphone ///due to too many diffs between android and ios ones var actIndIphone...