Skip to content

Instantly share code, notes, and snippets.

@meeech
Created August 23, 2012 06:28
Show Gist options
  • Save meeech/3433382 to your computer and use it in GitHub Desktop.
Save meeech/3433382 to your computer and use it in GitHub Desktop.
example for bug report
//bug: Cannot remove child view from inside TableViewRow
//2 cases
//A: .remove() View inside TableViewRow - Crash
//B: .remove() View nested in View inside TableViewRow - No Crash, but no effect
//Tested
//Android: 4.1, 2.3.3
//TiSDK: 2.1.2.v20120821160113, 2.1.1GA
var table = Ti.UI.createTableView({
minRowHeight: 45
});
//First Case:
//View inside row cannot be remove()
var rowA = Ti.UI.createTableViewRow({
backgroundColor: '#fff'
});
var viewA = Ti.UI.createView({
borderWidth: 1,
borderColor: '#f00',
left: 5, right: 5, top: 5, bottom: 5
});
rowA.add(viewA);
rowA.addEventListener('click', function(e) {
Ti.API.info('Row A click');
//Crash!
//in real world use, sometimes get this crash,
//sometimes remove call just fails silently
rowA.remove(viewA);
});
//Row B - Nested View
//I remove viewB from viewContainer but theres no effect.
var rowB = Ti.UI.createTableViewRow({
backgroundColor: '#fff'
});
var viewContainer = Ti.UI.createView({
borderWidth: 1,
borderColor: '#0f0',
left: 0,right: 0, top: 0,bottom: 0
});
var viewB = Ti.UI.createView({
borderWidth: 1,
borderColor: '#f0f',
backgroundColor: '#ccc',
left: 5, right: 5, top: 5, bottom: 5
});
viewContainer.add(viewB);
rowB.add(viewContainer);
rowB.addEventListener('click', function(e) {
Ti.API.info('Row B click');
viewContainer.remove(viewB);
});
table.setData([rowA, rowB]);
var win = Ti.UI.createWindow({
backgroundColor: "#ccc",
fullscreen: true
});
win.add(table);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment