Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-13499

iOS: ListView row still selected when returning to the window

    Details

      Description

      Problem
      When selecting a row and navigating to the next screen then tapping back to the window with the listview the selected row is still selected. Apple will reject apps with this behavior.

      Expected Behavior
      The listview should be deselected when returning to the window.

      Requested Feature
      This control also needs to a method to support deselectItem

      Steps to Reproduce
      1. Copy and paste code provided below into app.js
      2. Run on 3.1.xx or higher on iOS
      3. Click "Open ListView Tests" button
      4. Click "Basic" ListViewRow
      5. Click on any row
      6. Click back nav button
      7. Notice "Basic" is still selected

      var rootWin;
      var isAndroid = Ti.Platform.osname == 'android';
       
      function createAndroidNavGroup() {
      	return {
      		open : function(openWin, props) {
      			openWin.fullscreen = true;
      			openWin.backgroundColor = 'blue';
      			openWin.open();
      		}
      	}
      }
       
      var navGroup = isAndroid ? createAndroidNavGroup() : Ti.UI.iPhone.createNavigationGroup({
      	window : rootWin = Ti.UI.createWindow()
      });
       
      var button = Ti.UI.createButton({
          title: 'Open ListView Tests'
      });
      button.addEventListener('click', function() {
      	openTestsWindow();
      });
      var label = Ti.UI.createLabel({
      	text: "Return to this screen to check for memory leaks.\nEnsure garbage collection by doing 'Simulate Memory Warning'",
      	left: 5,
      	color: 'red',
      	bottom: 20
      });
      if (isAndroid) {
      	var navWin = Ti.UI.createWindow({ backgroundColor: 'white' });
       
      	navWin.add(button);
      	navWin.add(label);
      } else {
      	rootWin.add(button);
      	rootWin.add(label);
       
      	var navWin = Ti.UI.createWindow();
      	navWin.add(navGroup);
      }
      navWin.open();
       
       
      function openTestsWindow() {
      	var win = Ti.UI.createWindow({
      		title : 'ListView Tests'
      	});
      	var listView = Ti.UI.createListView();
       
      	var section = Ti.UI.createListSection({
      		headerTitle : 'Items'
      	});
      	section.setItems([{
      		properties : {
      			title : 'Basic',
      			itemId : 'basic',
      			accessoryType : Ti.UI.LIST_ACCESSORY_TYPE_DISCLOSURE
      		}
      	}]);
      	listView.appendSection(section);
       
      	listView.addEventListener('itemclick', function(e) {
      		var f = tests[e.itemId];
      		if (f)
      			f();
      	});
      	win.add(listView);
      	navGroup.open(win, {
      		animated : true
      	});
      }
       
      var tests = {};
       
      tests.basic = function() {
      	var win = Ti.UI.createWindow({
      		title : 'Basic'
      	});
      	var section = Ti.UI.createListSection();
      	var items = [];
      	for (var i = 0; i < 1000; ++i) {
      		items.push({
      			properties : {
      				title : 'Item ' + i
      			}
      		});
      	}
      	section.setItems(items);
      	var listView = Ti.UI.createListView({
      		sections : [section]
      	});
      	win.add(listView);
      	navGroup.open(win, {
      		animated : true
      	});
      }
      

        Attachments

          Activity

            People

            • Assignee:
              mstepanov Max Stepanov
              Reporter:
              clathrop Carter Lathrop
              Reviewer:
              Vishal Duggal (Inactive)
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-16197
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration