Creating a UIActionSheet

I would like to create such a menu, of course, using other menu buttons. Is there any standard view manager representing it, or do I need to get the images and create it myself.

enter image description here

+58
ios objective-c uiactionsheet
Jun 20 '13 at 20:30
source share
4 answers

You need to use UIActionSheet .

First you need to add the UIActionSheetDelegate to the UIActionSheetDelegate file.

Then you can reference the action table with:

  UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Select Sharing option:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: @"Share on Facebook", @"Share on Twitter", @"Share via E-mail", @"Save to Camera Roll", @"Rate this App", nil]; popup.tag = 1; [popup showInView:self.view]; 

Then you must handle each of the calls.

 - (void)actionSheet:(UIActionSheet *)popup clickedButtonAtIndex:(NSInteger)buttonIndex { switch (popup.tag) { case 1: { switch (buttonIndex) { case 0: [self FBShare]; break; case 1: [self TwitterShare]; break; case 2: [self emailContent]; break; case 3: [self saveContent]; break; case 4: [self rateAppYes]; break; default: break; } break; } default: break; } } 

This is deprecated for iOS 8.x https://developer.apple.com/documentation/uikit/uialertcontroller#//apple_ref/occ/cl/UIAlertController

+168
Jun 20 '13 at 20:34
source share

Take a look at the UIActionSheet documentation.

 NSString *actionSheetTitle = @"Action Sheet Demo"; //Action Sheet Title NSString *destructiveTitle = @"Destructive Button"; //Action Sheet Button Titles NSString *other1 = @"Other Button 1"; NSString *other2 = @"Other Button 2"; NSString *other3 = @"Other Button 3"; NSString *cancelTitle = @"Cancel Button"; UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:actionSheetTitle delegate:self cancelButtonTitle:cancelTitle destructiveButtonTitle:destructiveTitle otherButtonTitles:other1, other2, other3, nil]; [actionSheet showInView:self.view]; 
+11
Jun 20 '13 at 20:32
source share

It is called a UIActionSheet: you create it like this:

  NSString *actionSheetTitle = @"Action Sheet Demo"; //Action Sheet Title NSString *destructiveTitle = @"Destructive Button"; //Action Sheet Button Titles NSString *other1 = @"Other Button 1"; NSString *other2 = @"Other Button 2"; NSString *other3 = @"Other Button 3"; NSString *cancelTitle = @"Cancel Button"; UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:actionSheetTitle delegate:self cancelButtonTitle:cancelTitle destructiveButtonTitle:destructiveTitle otherButtonTitles:other1, other2, other3, nil]; [actionSheet showInView:self.view]; 

Deploy a UISctionSheetDelegate to respond to a button action.

Take a look at this tutorial for more information: http://mobile.tutsplus.com/tutorials/iphone/uiactionsheet_uiactionsheetdelegate (Code from this lesson)

+5
Jun 20 '13 at 20:34
source share
+3
Jun 20 '13 at 20:33
source share



All Articles