标签:
1 // 2 // ViewController.m 3 // UIActionSheet详解 4 // 5 // Created by 大欢 on 16/1/25. 6 // Copyright © 2016年 bjsxt. All rights reserved. 7 // 8 9 #import "ViewController.h" 10 11 @interface ViewController ()<UIActionSheetDelegate> 12 13 - (IBAction)showActionSheet:(id)sender; 14 15 @end 16 17 @implementation ViewController 18 19 - (void)viewDidLoad { 20 [super viewDidLoad]; 21 22 } 23 24 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 25 26 switch (buttonIndex) { 27 case 0: 28 NSLog(@"确定"); 29 break; 30 case 1: 31 NSLog(@"可以"); 32 break; 33 case 2: 34 NSLog(@"取消"); 35 break; 36 default: 37 break; 38 } 39 40 } 41 42 - (IBAction)showActionSheet:(id)sender { 43 44 UIActionSheet * sheet = [[UIActionSheet alloc] initWithTitle:@"题目" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:@"可以", nil]; 45 46 [sheet showInView:self.view]; 47 48 [self performSelector:@selector(dismissActionSheet:) withObject:sheet afterDelay:5]; 49 50 } 51 52 - (void)dismissActionSheet:(UIActionSheet *)sheet { 53 54 [sheet dismissWithClickedButtonIndex:0 animated:YES]; 55 } 56 57 58 @end
标签:
原文地址:http://www.cnblogs.com/MrWuYindi/p/5158886.html