I would like to implement a UIAlertViewController
like this (Reference: Pages and Keynote app):
.
I have implemented a custom tableview and presented the view by mimicking the UIAlertViewController
. But I cannot achieve a similar UI as above. Is there any default controller available for this?
-(void)share:(id)sender
{
[self setModalPresentationStyle:UIModalPresentationCurrentContext];
AlertViewController *renameCntrl = [self.storyboard instantiateViewControllerWithIdentifier:AlertTblViewidentifier];
renameCntrl.optionViewDelegate = self;
renameCntrl.providesPresentationContextTransitionStyle = YES;
renameCntrl.definesPresentationContext = YES;
[renameCntrl setModalPresentationStyle:UIModalPresentationOverCurrentContext];
[self presentViewController:renameCntrl animated:YES completion:nil];
}
method. UIKit displays alerts and action sheets modally over your app's content. In addition to displaying a message to a user, you can associate actions with your alert controller to give people a way to respond. For each action you add using the addAction(_:)
UIAlertController
has a private contentViewController
property which allows you to set any UIViewController
subclass as part of the alert controller. It works well with both action sheet or alert styles. You can mix content view controller with other alert actions.
This is how UIActivityViewController
, the Airdrop preview controller, etc. are implemented.
Best practice is to subclass UIAlertController
, and in either initWithNibName:bundle:
or viewDidLoad
, use setValue:forKey:
to set the contentViewController
property. Don't forget to set the preferredContentSize
for your content view controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With