iOS Dialog Boxes

From Xojo Documentation

Message Box

A Message Box displays a prompt for the user. Although it is a UI control, it does not appear on the Layout so when you drag it to your Layout, it is added to the Shelf. To learn more about Message Box go to the UserGuide:iOS Message Box topic.

Modal Views

A modal view is a view that is also displayed without being "pushed" onto the current view. A modal view cannot have toolbars and should not have other views pushed onto it. You can show and close a modal view using a Declare command to specific CocoaTouch APIs. To display a view modally:

Var v As New ModalView

// Display ModalView modally
Declare Sub presentViewController Lib "UIKit" _
Selector "presentViewController:animated:completion:" _
(parentView As Ptr, viewControllerToPresent As Ptr, animated As Boolean, completion As Ptr)

presentViewController(Self.Handle, v.Handle, True, Nil)

A button on the modal view is needed to close it:

// Close the Modal view to return to the calling view
Declare Sub dismissViewController Lib "UIKit" _
Selector "dismissViewControllerAnimated:completion:" _
(parentView As Ptr, animated As Boolean, completion As Ptr)

dismissViewController(Self.Handle, True, Nil)

Sample Project

  • Examples/iOS/Declares/ModalView

Also refer to the iOSDesignExtensions open-source project which has more complete support for this.

See Also

iOSMessageBox class; UserGuide:iOS UI, UserGuide:iOS Views, UserGuide:iOS Message Box topic