Here is my code:
local tabBarPress(event)
--handle result of button press in alert view.
local function onAlertComplete( event )
if "clicked" == event.action then
if event.index == 1 then
--do nothing, but revert tab bar to the last button that was pressed
tabs:pressButton( lastScreenSelected, false )
elseif event.index == 2 then
--go back to login screen
storyboard.gotoScene( "screen5" )
end
end
end
-- Show alert with two buttons
local alert = native.showAlert( "Logout", "Are you sure you want to logout?",
{ "No", "Yes" }, onAlertComplete )
return true
end
Now if I just put storyboard.gotoScene( “screen5” ) in the tabbar button press that works fine. However if I put it in the onAlertComplete function I get this error:
Runtime error
bad argument #-2 to ‘insert’ (Proxy expected, got nil)
stack traceback:
[C]: ?
[C]: in function ‘insert’
?: in function ‘?’
?: in function ‘gotoScene’
main.lua:1618: in function ‘_listener’
?: in function <?:534>
?: in function <?:229>
Does anyone have any idea what could be happening here?
I need the alert view to make sure the user gets the chance to change their mind if they hit the “logout” tab by mistake.
[import]uid: 84115 topic_id: 33345 reply_id: 333345[/import]