Code differences
In cases where you are coding an Android- or iOS-specific feature or, perhaps, working around an issue on a specific platform, there is an easy technique to determine the platform on every component. Each component that wraps a native component has either an .ios
or an .android
property that is used to access the actual underlying native component. If we wanted to select all the text inside the myText
text box, we can do so as follows:
var myText = frame.topmost().getViewById('myText'); if (myText.android) { console.log('We are running on Android'); myText.android.selectAll(); } else if (myText.ios) { console.log("We are running on iOS"); var range = new NSRange(); range.location = 0; range.length = myText.text.length; myText.ios.selectedRange = range; }
If you want only the code to be executed on iOS, check for the .ios
property on the component and then add whatever the specific code is for iOS. On Android, it is the .android
property. Each platform has its...