Changing scenes while a tableView is still scrolling?

I’m using tableView.lua to display a table and director.lua to manage scenes.

When I change scenes while a tableView is in motion, the terminal fills with multiple errors that look like this:

…/tableView.lua:354: attempt to perform arithmetic on field ‘y’ (a nil value)

It looks like tableView.lua is attempting access a table that no longer exists after the scene change. I’d say that about 25% of the time the app will crash (usually it happens when I give my table a good spin just before changing scenes).

What is the best way to deal with this issue? [import]uid: 54276 topic_id: 9512 reply_id: 309512[/import]

You will need to clean the tableView up, I’m going to assume that you are using Director so simply add a “clean” function like this to your screen:

[code]

function clean()
tableViewObject:cleanUp()
end

[/code] [import]uid: 5833 topic_id: 9512 reply_id: 34782[/import]

I knew it had to be something simple like that. Thank you, now it works perfectly! [import]uid: 54276 topic_id: 9512 reply_id: 34783[/import]

No worries, glad it got fixed! [import]uid: 5833 topic_id: 9512 reply_id: 34784[/import]

I was getting those same “attempt to perform arithmetic on field ‘y’ (a nil value)” errors when using tableViewXL.lua and noticed there were some lines missing in the tableViewXL’s CleanUp() function which are present in the tableView.lua (compare the two files here: https://bitbucket.org/gilbert/table-view-library/src):

Basically I just added the four “Runtime:removeEventListener” lines.

function listView:cleanUp() Runtime:removeEventListener("enterFrame", moveCat ) Runtime:removeEventListener("enterFrame", scrollList ) Runtime:removeEventListener( "enterFrame", showHighlight ) Runtime:removeEventListener("enterFrame", trackVelocity) local i for i = listView.numChildren, 1, -1 do --test listView[i]:removeEventListener("touch", newListItemHandler) listView:remove(i) listView[i] = nil end end [import]uid: 48658 topic_id: 9512 reply_id: 105759[/import]