#import <UIKit/UIKit.h>

@interface ViewController : UIViewController<UIActionSheetDelegate>

{

UILabel *lable;

}

@end

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

UIButton *button2=[UIButton buttonWithType:UIButtonTypeCustom];

button2.backgroundColor=[UIColor greenColor];

button2.frame=CGRectMake(100, 200, 120, 50);

[button2 addTarget:self action:@selector(showmyActionSheet:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:button2];

}

-(void)showmyActionSheet:(UIButton *)sender

{

UIActionSheet *actionSheet1=[[UIActionSheet alloc]initWithTitle:@"ActionSheet" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"red color" otherButtonTitles:@"blue color",@"black color", nil];

NSLog(@"%@",[actionSheet1 buttonTitleAtIndex:0]);

[actionSheet1 showInView:self.view];

}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

{

if (buttonIndex==0) {

self.view.backgroundColor=[UIColor redColor];

}

else if (buttonIndex==1){

self.view.backgroundColor=[UIColor blueColor];

}

else if (buttonIndex==2)

{

self.view.backgroundColor=[UIColor blackColor];

}

}

//ActionSheet已经消失的方法

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex

{

lable.text=@"已经消失";

}

//

- (void)actionSheetCancel:(UIActionSheet *)actionSheet{

lable.text=@"zheshism";

}

//将要出现

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet{

lable.text=@"将要出现";

}

//已经出现

- (void)didPresentActionSheet:(UIActionSheet *)actionSheet{

lable.text=@"已经出现";

}

//将要消失

- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex{

lable.text=@"将要消失";

}

UIActionSheet的更多相关文章

  1. 弹框控件 UIAlertView UIActionSheet

    // 创建弹框 从底部弹出,一般用于危险操作 UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"恭喜通关" ...

  2. UI第十三节——UIActionSheet

    - (void)viewDidLoad {    [super viewDidLoad];        UISwitch *swc = [[UISwitch alloc] initWithFrame ...

  3. 【代码笔记】iOS-清除图片缓存UIActionSheet

    一,效果图. 二,代码. RootViewController.m //点击任何处出现sheet -(void)touchesBegan:(NSSet *)touches withEvent:(UIE ...

  4. UIAlertView 与 UIActionSheet (提示用户)的使用方法

    UIAlertView 提示用户  帮助用户选择框 //    UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"警 ...

  5. UI里的UIActionSheet按钮

    1.效果图:分别为有短信分享                                      无短信分享 -(void)viewDidLoad{ //添加按钮 UIButton *share ...

  6. UIActionSheet的使用

    UIActionSheet是在iOS弹出的选择按钮项,可以添加多项,并为每项添加点击事件. 为了快速完成这例子,我们打开Xcode 4.3.2, 先建立一个single view applicatio ...

  7. UIAlertView、 UIActionSheet

    一.UIAlertView. UIActionSheet都是ios系统自带的弹出式对话框,当UIAlertView或UIActionSheet弹出来时用户无法与应用界面中的其它控件交互,UIAlert ...

  8. IOS笔记之UIKit_UIAlertView、UIActionSheet

    //首先必须继承协议 @interface TRViewController : UIViewController<UIAlertViewDelegate,UIActionSheetDelega ...

  9. UIActionSheet 修改字体颜色

    -(void)willPresentActionSheet:(UIActionSheet *)actionSheet { SEL selector = NSSelectorFromString(@&q ...

  10. 封装同步的UIActionSheet

    封装同步的UIActionSheet 发问题 做 iOS 开发的同学想必都用过 UIActionSheet.UIActionSheet 可以弹出一个选择列表,让用户选择列表中的某一项操作.使用 UIA ...

随机推荐

  1. LINUX CACHE IO THREAD

    http://www.penglixun.com/tech/system/linux_cache_discovery.html http://my.oschina.net/HardySimpson/b ...

  2. [022]c++虚函数、多态性与虚表

    原文出处:http://my.oschina.net/hnuweiwei/blog/280894 目录[-] 多态 虚函数 纯虚函数 虚表 一般继承(无虚函数覆盖) 一般继承(有虚函数覆盖) 多重继承 ...

  3. Cloudera Error: "Failed to handle Heartbeat Response"

    在使用cloudera manager安装CDH过程中,发现安装进程卡在给某个slave机分配parcel上. 查agent的log发现如下错: ...MainThread agent ERROR F ...

  4. NSOperation使用系统提供子类的方法--处理复杂任务

    //创建一个队列 NSOperationQueue *operation=[[NSOperationQueue alloc]init]; //把任务放在NSBlockOperation里面 NSBlo ...

  5. [Arduino] 在串口读取多个字符串,并且转换为数字数组

    功能如题目.在串口收到逗号分割的6串数字比如100,200,45,4,87,99然后在6个PWM端口3, 5, 6, 9, 10, 11输出对应PWM值代码注释很详细了,就不再说明了. //定义一个c ...

  6. Android中GridLayout与GridView区别

    GridLayout初步研究:可以这么说这个布局绝对是开发者的福音,它大大简化了对复杂布局的处理,包括性能提高不是一倍两倍.它与GridView是完全不同的概念, GridView是一种适配器布局,它 ...

  7. iis8 默认不支持svc解决方法

    最近在IIS8中发布WCF服务应用时,发现IIS8不支持WCF服务svc请求,后来发现IIS8缺少对WCF服务的Managed Handler,按照以下步骤添加后,IIS8即支持WCF服务. 1. 首 ...

  8. Zendstudio 9.0.2 安装Aptana3 并且配置 jQuery

    Zendstudio 9.0.2 安装Apnata3 并且配置 jQuery aptana-javascript-jquery.ruble文件夹下载地址: http://dl.dbank.com/c0 ...

  9. MyEclipse设置编码方式 转载【http://www.cnblogs.com/susuyu/archive/2012/06/27/2566062.html】

    1.windows->Preferences……打开"首选项"对话框,左侧导航树,导航到general->Workspace, 右侧Text file encoding ...

  10. Matlab之文件操作

    1.判断是否存在文件夹:if (exist(folderName,'dir')) 2.创建文件夹:mkdir(folderName) 3.删除文件夹:rmdir(folderName,'s') 4.当 ...