ricky3350
ricky3350

Reputation: 1738

Action on UIAlertController that does not dismiss AlertController? (Disable dismissing)

I have an action sheet (UIAlertController with style of UIAlertControllerStyleActionSheet) with a few actions, presented on an iPad as a popover. What I want is, when a user selects one of the options (say, the first one), I want the action sheet to transition to a different action sheet, using the "Show" (previously "Push") animation. Is this possible? Or, if this is not possible, is it possible to present the second action sheet as a popover from the action tapped (I'd prefer the transition method, if possible).

Thanks in advance!

Upvotes: 0

Views: 2772

Answers (1)

matt
matt

Reputation: 536027

The nice thing about iOS 7 and 8 in this regard is that it really is quite easy to write a view controller that looks and acts like an alert - except that it's just a view controller, so you can put any content you like into it and you can make it behave however you want.

For an example, see this github project of mine: https://github.com/mattneub/custom-alert-view-iOS7

As you'll see, all we're doing is starting with a small view designed in a .xib file and controlled by a view controller. Then we present the view controller. This view controller knows how to animate the appearance of the view and put a "dimmer" view behind it, just like an alert! And indeed this is not surprising, because in iOS 8 an alert controller is a presented view controller, so there's no reason why you shouldn't imitate its behavior. It isn't doing anything you can't do yourself.

Upvotes: 4

Related Questions