Problems with native.showAlert on iPad

Let me preface this by saying I have a tester who has an iPad so it’s a slow testing process for me. :slight_smile:

I have an info button (ui class). I catch the release for that specific button id and make the following call:

native.showAlert(“Info”, “This is some info”, { “Ok” });

Works in the simulator. Works on the iPhone. However, on the iPad the behavior is not so good.

The first response from my tester was that pressing Ok did not dismiss the dialog.

Under closer scrutiny, he says that when he presses the Ok button, he can see the alert closing, but immediately underneath it another one opens.

I have tried adding code to cancel the alert:

infoAlertId = nil;
function reallyCloseAlert(event)
native.cancelAlert(infoAlertId);
end
infoAlertId = native.showAlert(“Info”, “This is some info”, { “Ok” }, reallyCloseAlert);

Same result. Same thing happens when I change to two buttons (Yes/No) and use the resulting index, etc.

This has been tested with 1.3beta, 2.0b1, and 2.0b2. So, it appears to be a bug for the iPad.

Aside from that, there’s another issue: The alert is taking anywhere from 3-5+ seconds to pop up initially.

Scott [import]uid: 5659 topic_id: 911 reply_id: 300911[/import]

I’ve got a little quicktime vid of this if you want me to send it to you (you being someone at Ansca). [import]uid: 5659 topic_id: 911 reply_id: 2119[/import]

I prefer you send me some code. I just did a test and seems to work on my iPad
C [import]uid: 24 topic_id: 911 reply_id: 2126[/import]

Okay, I’ll build up a test case and make sure it’s not something odd in my code… assuming it continues to fail I’ll post it or mail it.

Thanks,
Scott [import]uid: 5659 topic_id: 911 reply_id: 2134[/import]

Okay, I have a test case for you where the behavior exists.

I just need an email address to send the zip to…

Scott [import]uid: 5659 topic_id: 911 reply_id: 2166[/import]

info@anscamobile.com [import]uid: 24 topic_id: 911 reply_id: 2171[/import]

Okay, I sent it in. Thanks! [import]uid: 5659 topic_id: 911 reply_id: 2173[/import]

Got it.

c [import]uid: 24 topic_id: 911 reply_id: 2177[/import]

Were you able to reproduce the problem on your iPad? I ask because if not, it means there’s something wrong on my end that I somehow need to track down.

Thanks,
Scott [import]uid: 5659 topic_id: 911 reply_id: 2191[/import]

Anyone else out there with an iPad… can you test this to confirm it happens on someone else’s iPad?

It’s very straightforward code and if you have suggestions for how to fix the problem, please reply!

Thanks!

http://www.spowers.net/TestMe/

Scott

[import]uid: 5659 topic_id: 911 reply_id: 2225[/import]

Opened as case # 170 [import]uid: 54 topic_id: 911 reply_id: 2238[/import]

Carlos/Eric,

Carlos indicated earlier that a simple test on his iPad did not see this problem, so I sent in a stripped down version of our code where we see the problem happen.

I see you’ve opened a case # now and I’d like to clearly know if you guys are actually seeing the problem? Specifically, have you had the time to run the code I sent in yet?

Thanks,
Scott [import]uid: 5659 topic_id: 911 reply_id: 2247[/import]

Got it !

Try this sample and see if it works on your iPad. Your button handler was causing it to show the alert when you clicked not on release. the button wasn’t even highlighting properly.

[code]



– MODULES



local ui = require(“ui”);

local _alertWeb = nil;

local function onProductWebPageComplete(event)
native.cancelAlert(_alertWeb);

return true;

end
local function buttonHandler( event )
if (event.phase == “release” ) then – < _alertWeb = native.showAlert(“TestMe”,
“Do you want to view the TestMe page at the website via Safari?”,
{ “Yes”, “No” },
onProductWebPageComplete);

return false;
end

end



– INTERFACE LAYOUT



– Initialize the display

local function main ()

display.setStatusBar(display.HiddenStatusBar);

_buttonWebsite = ui.newButton {
default = “buttonWWWLight.png”,
over = “buttonWWWLightOver.png”,
onEvent = buttonHandler,
– id = “url”,
x = 100; --_orientation[_currentOrientation].website.x,
y = 60-- _orientation[_currentOrientation].website.y,
};

end

main()

[/code] [import]uid: 24 topic_id: 911 reply_id: 2280[/import]

Source formatting is awful.

Sorry about that, but copy paste that code into your main.lua file that you sent me and see if it works.

Carlos [import]uid: 24 topic_id: 911 reply_id: 2281[/import]

I reviewed the code I sent you and the test for the event.phase was originally all there, you just removed some stuff and likely knocked out that line as well.

Here’s the original:

function buttonHandler(event)  
 needToSync = nil;  
  
-- print("id = " .. event.id .. ", phase = " .. event.phase);  
 if (event.phase == "release") then  
 if (event.id == "url") then  
 -- pop a question dialog, do you want to view the web page for SoundSpinner via Safari?  
 -- if yes, then open url  
 \_alertWeb = native.showAlert("TestMe",  
 "Do you want to view the TestMe page at the website via Safari?",  
 { "Yes", "No" },  
 onProductWebPageComplete);  
 elseif (event.id == "info") then  
 \_alertInfo = native.showAlert("TestMe",  
 "INFO -- FEED ME",  
 { "Ok" },  
 onInfoComplete);  
 end  
 end  
end  

[import]uid: 5659 topic_id: 911 reply_id: 2283[/import]

agh …

still happening.ok. let me try something else here.

c. [import]uid: 24 topic_id: 911 reply_id: 2284[/import]

confirmed bug

will prioritize and ask engineering to see if we can get a fix by next beta drop

i think it is the ui.lua that is causing this as i re-did the buttons using the addEventListeners and it worked…

c. [import]uid: 24 topic_id: 911 reply_id: 2310[/import]

Okay, please do note that I modified ui.lua to allow for sending of button “moved” events if requested.

Those changes are documented there. I just did a test with the standard ui.lua and the very same problem exists, so it was not that.

Just wanted to avoid any "ahhh ha!"s that don’t pan out. :slight_smile:

On that note though, allowing for us to handle moved events on buttons is very nice since we can swap out textures if we need to (like for a toggle button that has different colored text when pushed down). A separate item that I submitted a while back. I’ll have to go back in and see if that got added or not in the feature requests.

Thanks for the workaround as well, I’ll probably just implement them in that fashion… unless the next beta drop is happening sometime say… within a week? *nudge* *nudge*

I’m really looking forward to being able to use 2.0b3 for iPad development (2.0b2 simulator is hosed because of a zoom issue on startup… hope that one got fixed!).

Thanks for the hard work in tracking/fixing this!

Scott [import]uid: 5659 topic_id: 911 reply_id: 2319[/import]

This is fixed in 2.0 Beta 3, which just went live. Bug #170 closed. [import]uid: 3007 topic_id: 911 reply_id: 2411[/import]