You can create action sheet in iOS 8 or later version using UIAlertController .Following is the sample code for creating action sheet using UIAlertController-
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Action Sheet" message:@"Action Sheet example using UIAlertController " preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
NSLog(@"Cancel button tapped");
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
NSLog(@"Delete button tapped");
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Create" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"Create button tapped");
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Select All" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"Select All button tapped");
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[self presentViewController:actionSheet animated:YES completion:nil];
Following is the sample screen shot of action sheet using UIAlertController-
Leave Comment