Search code examples
ios7uialertviewuiactionsheet

Is there a way to show a message (like UIAlertView) from a modal UIPopover?


I have an iPad app that uses a UIPopover from within a UIVIew; I need to show an alert-type message when a certain condition has been met.

The problem is using a UIAlertView from within the UIPopover, when the user taps on a button in the UIAlertView, it also dismisses the UIPopover, which defeats the purpose of the alert.

I tried using UIActionSheets, but they don't display at all, probably because they are not being called from a controller-type view.

Is there a way to circumvent this behavior?


Solution

  • No, and you shouldn't do that. Popovers are supposed to go away as soon as you touch anything else.

    You could enlarge the popover slightly and make room for a status message. When the user creates an appointment that overlaps, you could display a message in the status area.

    Or, you could dismiss the popover and display an alert with "ok"/"cancel" buttons. The OK button would create the overlapping appointment, and the cancel button would discard it.

    You will need some place to save the info from the popover while you are waiting for the user to decide what to do with the alert. Perhaps have the popover pass a message back to the view controller it comes from, and then have the source view controller create the alert, set itself as delegate, and handle the responses from the user.