Using the Alert Sheet from the example, I set up my project with a subclass of iOSView that has a ShowMessageBox method and an ActionSheetResult Event Definition. Makes it very easy to handle this type of problem for multiple views. Please note that I assed the MyTag as text variable to the alert sheet class from the example.
In your iOSView subclass, the method you’ll call when you want to show the message box:
[code]Sub ShowMessageBox(boxTag as text, theMessage as text, buttons() as text, cancelButtonName as text=“Cancel”)
if buttons=nil or UBound(buttons)=-1 then
Return
end if
dim xx as new AlertSheet
xx.MyTag = boxTag
xx.CancelButton = cancelButtonName
xx.ActionButtons = buttons
xx.Message = theMessage
AddHandler xx.ButtonAction, AddressOf ButtonResult
xx.Show(me)
End Sub
[/code]
Then the ButtonResult private method:
Sub ButtonResult(sender as alertSheet, buttonIndex as integer, cancel as Boolean)
if cancel=false then
RaiseEvent ActionSheetResult(sender.myTag, buttonIndex)
end if
End Sub
And the event definition:
Event ActionSheetResult(sheetTag as text, buttonIndex as integer)
Sub ()
Now whenever you want to call a message box with a response it’s very simple, you’ll just make sure your view is the iOSView subclass, and then use:
self.ShowMessageBox("someTag","Do you want to do that?",Array("Yes", "Maybe","Sure"))
And then implement the ActionSheetResult with something like:
select case sheetTag
case "someTag"
select case buttonIndex
case 0//yes
self.pushTo(someView)
case 1//maybe
case 2//sure
end select
end select