Problem
Unless the [Titanium.UI.Switch.value](
http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.UI.Switch-property-value) property has been set, the switch does not render on iOS.
This is not necessary for Android, so adding the parity label to this ticket.
Test Case
var win = Ti.UI.createWindow({
backgroundColor: 'white',
layout: 'vertical'
});
function printSwitchProperties(obj){
var props = ['enabled', 'value'];
for (var p in props){
Ti.API.info('Switch property ' + props[p] + ': '+ obj[props[p]]);
}
}
var basicSwitch = Ti.UI.createSwitch({
// value:true // uncomment to display switch
});
win.add(basicSwitch);
printSwitchProperties(basicSwitch);
basicSwitch.addEventListener('change',function(e){
printSwitchProperties(e.source);
});
win.open();
it works fine on android but doesn't works in iOS iOS console : [INFO] : Switch property enabled: undefined [INFO] : Switch property value: undefined Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 (03/11/13 15:43 0c88429) Titanium SDK version: 3.0.2 (02/07/13 16:46 a4def81) iOS iPhone Simulator: iOS SDK version: 6.0 Device: Samsung galaxy s duos Android version: 4.0.4 jithinpv
PR: https://github.com/appcelerator/titanium_mobile/pull/8278
PR (unit-test): https://github.com/appcelerator/titanium-mobile-mocha-suite/pull/3
Approved!
Verified as fixed. UI.Switch on the iOS platform now displays even if the value is not set when rendered. Tested On: iPhone 6 Plus 10.1.1 Device & Simulator Mac OS Sierra (10.12.1) Ti SDK: 6.1.0.v20161116071014 Appc Studio: 4.8.0.201611121409 Appc NPM: 4.2.8 App CLI: 6.1.0-14 Xcode 8.1 Node v4.4.7 *Closing ticket.*