码迷,mamicode.com
首页 > 移动开发 > 详细

iOS学习-UIActionSheet详解

时间:2016-01-25 22:55:13      阅读:446      评论:0      收藏:0      [点我收藏+]

标签:

 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

技术分享

iOS学习-UIActionSheet详解

标签:

原文地址:http://www.cnblogs.com/MrWuYindi/p/5158886.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!