Tutorial details

Action Sheet | App Code for Sale | Preview

Action Sheet | iOS Tutorial

How to create a action sheet and add actions to the buttons

Overview PAGE TOP

Reference: http://www.geekylemon.com/WEBPROTECT-xcodeactionsheet.htm

In this tutorial i will be showing you how to create a action sheet and add actions to the buttons

Features:

  • 1 Round rect button
  • 1 Label

Action sheets are basically menus containing many actions ready for the user to perform, action sheets pop up over the current view with a list of buttons giving the user options which your current view cannot display

ViewController.h PAGE TOP

@interface ViewController :UIViewController <UIActionSheetDelegate> {
IBOutlet UILabel *label;
}
-(IBAction)ActionSheetButton; 
@end

ViewController.m PAGE TOP

@implementation ViewController
-(IBAction)ActionSheetButton {
UIActionSheet *actionsheet = [[UIActionSheet alloc]                                   
initWithTitle:@"Title"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Button1",@"Button2", nil];
    [actionsheet showInView:self.view];    
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
label.text = @"Button 1 was pressed";
    }
if (buttonIndex == 1) {
label.text = @"Button 2 was pressed";
    }
} 
@end

Reference PAGE TOP

http://www.geekylemon.com/WEBPROTECT-xcodeactionsheet.htm

0 Comments Leave a comment

Please login in order to leave a comment.

Newest first
!

Sign-in to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.