Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1578] iOS: Trying to remove a previously removed view from a scrollableView has unexpected results

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-07-25T16:49:17.000+0000
Affected Version/sRelease 1.5.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterThomas Huelbert
AssigneeNeeraj Gupta
Created2011-04-15T02:56:33.000+0000
Updated2012-07-26T22:22:27.000+0000

Description

Using the code below,
1.launch the app, tap "remove view 3"
2.note the view was removed, tap the button again
results:view 2 seems to have been removed as well as objects on it.

var win = Titanium.UI.currentWindow

//create view to show var view1 = Titanium.UI.createView({backgroundColor:'#123'});
var view2 = Titanium.UI.createView({backgroundColor:'#456'});
var view3 = Titanium.UI.createView({backgroundColor:'#789'});
//create scrollable to be populated by above var scrollView = Titanium.UI.createScrollableView({

views:[view1,view2,view3],
showPagingControl:true

});

//buttons for test var b1 = Ti.UI.createButton({

height:40,
width:200,
title:'Remove View 3',
top:160

});

view1.add(b1);

var text1 = Ti.UI.createLabel({

text:"view 1",
width:"auto",
height:"auto",
top:10,

})

view1.add(text1)

var text = Ti.UI.createLabel({

text:"view 2",
width:"auto",
height:"auto",
top:10,

})

view2.add(text)

var text3 = Ti.UI.createLabel({

text:"view 3",
width:"auto",
height:"auto",
top:10,

})

view3.add(text3)

//remove view3 b1.addEventListener('click', function()
{

scrollView.removeView(view3);

});

win.add(scrollView);

Comments

  1. Thomas Huelbert 2011-04-15

    formatting got hoopty above, trying again...

    var win = Titanium.UI.currentWindow

    var view1 = Titanium.UI.createView({backgroundColor:'#123'});
    var view2 = Titanium.UI.createView({backgroundColor:'#456'});
    var view3 = Titanium.UI.createView({backgroundColor:'#789'});

    var scrollView = Titanium.UI.createScrollableView({

       views:[view1,view2,view3],
       showPagingControl:true
       

    });

    var b1 = Ti.UI.createButton({

       height:40,
       width:200,
       title:'Remove View 3',
       top:160
       

    });

    view1.add(b1);

    var b2 = Ti.UI.createButton({

       height:40,
       width:210,
       title:'Remove View no target',
       top:210
       

    });

    view1.add(b2);

    var text1 = Ti.UI.createLabel({

       text:"view 1",
       width:"auto",
       height:"auto",
       top:10,
       

    })

    view1.add(text1)

    var text = Ti.UI.createLabel({

       text:"view 2",
       width:"auto",
       height:"auto",
       top:10,
       

    })

    view2.add(text)

    var text3 = Ti.UI.createLabel({

       text:"view 3",
       width:"auto",
       height:"auto",
       top:10,
       

    })

    view3.add(text3)

    b1.addEventListener('click', function()
    {

       scrollView.removeView(view3);
       

    });

    b2.addEventListener('click', function()
    {

       scrollView.removeView();
       

    });

    win.add(scrollView);

  2. hal 2011-04-15

    I have recoded this page to test the issue more fully and also to remove the syntax errors.

    On Android emulator this code seems to work without issue, and certainly not the issue you have described.

    Would you run this code in your environment to confirm that it is still and issue for you?

       var win = Titanium.UI.currentWindow;
       
       var view0 = Titanium.UI.createView({backgroundColor:'#123'});
       
       var text0 = Ti.UI.createLabel({
           text:"view 0",
           width:"auto",
           height:"auto",
           top:10
       });
       
       view0.add(text0);
       
       var b0 = Ti.UI.createButton({
           height:40,
           width:200,
           title:'Remove/Add View 2',
           top:140
       });
       
       view0.add(b0);
       
       var b1 = Ti.UI.createButton({
           height:40,
           width:200,
           title:'Remove View 2',
           top:200
       });
       
       view0.add(b1);
       
       var view1 = Titanium.UI.createView({backgroundColor:'#456'});
       
       var text1 = Ti.UI.createLabel({
           text:"view 1",
           width:"auto",
           height:"auto",
           top:10
       });
       
       view1.add(text1);
       
       var view2 = Titanium.UI.createView({backgroundColor:'#789'});
       
       var text2 = Ti.UI.createLabel({
           text:"view 2",
           width:"auto",
           height:"auto",
           top:10
       });
       
       view2.add(text2);
       
       var state = true;
       
       b0.addEventListener('click', function()
       {
           if(state){
               scrollableView.removeView(view2);
               Ti.API.info('view 2 removed');
               state = false;
           } else {
               scrollableView.addView(view2);
               Ti.API.info('view 2 added');
               state = true;
           }
       });
       
       var removeNumber = 0;
       b1.addEventListener('click', function()
       {
               scrollableView.removeView(view2);
               removeNumber++;
               state = false;
               Ti.API.info('removing view 2 for time: '+removeNumber);
       });
       
       var scrollableView = Titanium.UI.createScrollableView({
           views:[view0,view1,view2]
       });
       
       scrollableView.addEventListener('scroll', function(e){
           Ti.API.info('***************************************');
           Ti.API.info('scrollable view scroll currentPage: '+e.currentPage);
       });
       
       win.add(scrollableView);
       
  3. Stephen Tramer 2012-07-25

    Unable to reproduce described behavior via any of the provided tests in SDK 2.2.0.f9e938d on iPhone Sim 5.1.

JSON Source