#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. mysql 线程级别的缓冲区

    线程栈信息使用内存(thread_stack) 主要用来存放每一个线程自身的标识信息,如线程id,线程运行时基本信息等等,我们可以通过 thread_stack 参数来设置为每一个线程栈分配多大的内存 ...

  2. 下一个系列学习列表Spring.net+NHibernate+MVC

    开源框架完美组合之Spring.NET + NHibernate + ASP.NET MVC + jQuery + easyUI 中英文双语言小型企业网站Demo 刘冬.NET 2011-08-19 ...

  3. android学习日记13--数据存储之ContentProvide

    3.ContentProvider 数据在Android当中是私有的,当然这些数据包括文件数据和数据库数据以及一些其他类型的数据.ContentProvider实现多应用程序间的数据共享类一般利用Co ...

  4. C++ Traits技术

    要想深入的理解STL的迭代器.分配器等,就必须了解C++模板编程中的一个技巧——Traits. 1.问题的提出 C++的模板特性为泛型编程提供了支持.这样我们就可以编写更加通用的代码,而不必过分去关心 ...

  5. C# 自定义重绘TextBox

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  6. Load Balancing 折半枚举大法好啊

    Load Balancing 给出每个学生的学分.   将学生按学分分成四组,使得sigma (sumi-n/4)最小.         算法:   折半枚举 #include <iostrea ...

  7. 属性通知之INotifyPropertyChanged

    为什么后台绑定的值改变了前台不发生变化了? 针对这个初学者很容易弄错的问题,这里介绍一下INotifyPropertyChanged的用法 INotifyPropertyChanged:用于绑定属性更 ...

  8. 根据表结构自动生成JavaBean,史上最强最专业的表结构转JavaBean的工具(第2版)

             目录:                 第1版:http://blog.csdn.net/vipbooks/article/details/51912143              ...

  9. 如何写出好的Java代码?

    1. 优雅需要付出代价.从短期利益来看,对某个问题提出优雅的解决方法,似乎可能花你更多的时间.但当它终于能够正确执行并可轻易套用于新案例中,不需要花上数以时计,甚至以天计或以月计的辛苦代价时,你会看得 ...

  10. 使用Apache Felix Remote Shell远程管理OSGI

    通过Apache Felix Remote Shell提供的org.apache.felix.shell.remote能使用telnet客户端访问远程的[Apache Felix Shell]和[Ap ...