Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9007] iOS: UI.Switch - does not display if value is not set when rendered

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2016-08-29T09:19:20.000+0000
Affected Version/sRelease 2.0.1, Release 3.1.0
Fix Version/sRelease 6.1.0
ComponentsiOS
Labelsapi, parity
ReporterPaul Dowsett
AssigneeHans Knöchel
Created2012-05-06T07:11:30.000+0000
Updated2016-11-17T15:05:51.000+0000

Description

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();

Attachments

FileDateSize
iOS Simulator Screen shot Mar 22, 2013 4.46.15 PM.png2013-03-22T11:19:57.000+00005308
Screenshot_2013-03-22-15-58-11.png2013-03-22T11:19:57.000+000018613

Comments

  1. jithinpv 2013-03-22

    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
  2. Hans Knöchel 2016-08-28

    PR: https://github.com/appcelerator/titanium_mobile/pull/8278
  3. Hans Knöchel 2016-08-29

    PR (unit-test): https://github.com/appcelerator/titanium-mobile-mocha-suite/pull/3
  4. Chee Kiat Ng 2016-08-29

    Approved!
  5. Harry Bryant 2016-11-17

    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.*

JSON Source