App crash with 20+ ImageViews in ScrollableView
Does anyone know how to dynamically add and remove multiple ImageViews in a ScrollableView? If I have more than 20 ImageViews in the scrollableView of my app, it crashes.
7 Answers
-
I think 1.5 might solve the scrollableView crashing problem. Can anyone confirm this?
-
the solution i ended up with was adding extra logic such that only 3 views were in memory at a time.
my method wasnt very efficient but its decent i guess… everytime you touch the screen the app sets all views to null except for the current one. it then recreates the images immediately adjacent to the current view back so that when the user scrolls there isnt an abrupt change.
its worked thus far though my app is small. hopefully it continues to work as i expand to more views.
-
the solution i ended up with was adding extra logic such that only 3 views were in memory at a time.
my method wasnt very efficient but its decent i guess… everytime you touch the screen the app sets all views to null except for the current one. it then recreates the images immediately adjacent to the current view back so that when the user scrolls there isnt an abrupt change.
its worked thus far though my app is small. hopefully it continues to work as i expand to more views.
-
the solution i ended up with was adding extra logic such that only 3 views were in memory at a time.
my method wasnt very efficient but its decent i guess… everytime you touch the screen the app sets all views to null except for the current one. it then recreates the images immediately adjacent to the current view back so that when the user scrolls there isnt an abrupt change.
its worked thus far though my app is small. hopefully it continues to work as i expand to more views.
-
test is my scrollableview…
e.source.name2 is a unique int for each pagetest.addEventListener('touchstart', function(e){
var pagenumber = e.source.name2;
//pass in the unique identifier for each viewvar onepageback = Math.round(pagenumber) - 1;
//grab identifiers for the preceding and following view so that its seamless when the user scrollsvar onepagefwd = Math.round(pagenumber) + 1;
for (var q=0; q<pages.length; q++){
//erase all backgrounds except for the current one by assigning them an invalid image
if (q == pagenumber){
//do nothing to currentpage }else{ /
/erase all otherspages[q].setbackgroundImage('');
}
}//create views for 2 adjacent pages pages[onepageback].setbackgroundImage('images/backgrounds/pages' + onepageback + '.png'); pages[onepagefwd].setbackgroundImage('images/backgrounds/pages' + onepagefwd + '.png');
});
-
test is my scrollableview…
e.source.name2 is a unique int for each pagetest.addEventListener('touchstart', function(e){
var pagenumber = e.source.name2;
//pass in the unique identifier for each viewvar onepageback = Math.round(pagenumber) - 1;
//grab identifiers for the preceding and following view so that its seamless when the user scrollsvar onepagefwd = Math.round(pagenumber) + 1;
for (var q=0; q<pages.length; q++){
//erase all backgrounds except for the current one by assigning them an invalid image
if (q == pagenumber){
//do nothing to currentpage }else{ /
/erase all otherspages[q].setbackgroundImage('');
}
}//create views for 2 adjacent pages pages[onepageback].setbackgroundImage('images/backgrounds/pages' + onepageback + '.png'); pages[onepagefwd].setbackgroundImage('images/backgrounds/pages' + onepagefwd + '.png');
});
-
my app does the same thing, I load 12 images to a scrollview, finally, I found out it has little to do with the memory, because even when I load 12 tiny images, it crashes too, so it has something to do with the thread or loading mechanisim in Ti.
I ended up doing this, so far it is ok. Load 4 images at a time and then wait for 1 second or 0.5 second to load another 4. Now, I can load 12 1M images without issues.