UIActionSheet
#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的更多相关文章
- 弹框控件 UIAlertView UIActionSheet
// 创建弹框 从底部弹出,一般用于危险操作 UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"恭喜通关" ...
- UI第十三节——UIActionSheet
- (void)viewDidLoad { [super viewDidLoad]; UISwitch *swc = [[UISwitch alloc] initWithFrame ...
- 【代码笔记】iOS-清除图片缓存UIActionSheet
一,效果图. 二,代码. RootViewController.m //点击任何处出现sheet -(void)touchesBegan:(NSSet *)touches withEvent:(UIE ...
- UIAlertView 与 UIActionSheet (提示用户)的使用方法
UIAlertView 提示用户 帮助用户选择框 // UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"警 ...
- UI里的UIActionSheet按钮
1.效果图:分别为有短信分享 无短信分享 -(void)viewDidLoad{ //添加按钮 UIButton *share ...
- UIActionSheet的使用
UIActionSheet是在iOS弹出的选择按钮项,可以添加多项,并为每项添加点击事件. 为了快速完成这例子,我们打开Xcode 4.3.2, 先建立一个single view applicatio ...
- UIAlertView、 UIActionSheet
一.UIAlertView. UIActionSheet都是ios系统自带的弹出式对话框,当UIAlertView或UIActionSheet弹出来时用户无法与应用界面中的其它控件交互,UIAlert ...
- IOS笔记之UIKit_UIAlertView、UIActionSheet
//首先必须继承协议 @interface TRViewController : UIViewController<UIAlertViewDelegate,UIActionSheetDelega ...
- UIActionSheet 修改字体颜色
-(void)willPresentActionSheet:(UIActionSheet *)actionSheet { SEL selector = NSSelectorFromString(@&q ...
- 封装同步的UIActionSheet
封装同步的UIActionSheet 发问题 做 iOS 开发的同学想必都用过 UIActionSheet.UIActionSheet 可以弹出一个选择列表,让用户选择列表中的某一项操作.使用 UIA ...
随机推荐
- 关于Android(Java)创建匿名线程
Java中创建匿名线程主要集中就三中方式:Thread,Runnable,Handler去实现,下面分别介绍之- 一.通过Thread来创建 new Thread() { public void ru ...
- c++ 设计模式4 (Strategy)
3.2 Strategy (策略模式) 动机:在软件构建过程中,某些对象使用的算法可能多种多样,经常改变,如果将这些算法都编码到对象中,将会使对象变得异常复杂,而且有时候支持不使用或不常使用的算法也是 ...
- 关于MFC库和CRT库冲突的分析
当MFC库和CRT库冲突时,会出现一个LNK2005的错误.具体的错误如下: nafxcwd.lib(dllmodul.obj): error LNK2005: _DllMain@12 already ...
- UIScrollView做循环图片
#import "ViewController.h" #define IMAGE_COUNT 6 @interface ViewController () { UIImageVie ...
- sql over开窗函数
1.使用over子句与rows_number()以及聚合函数进行使用,可以进行编号以及各种操作.而且利用over子句的分组效率比group by子句的效率更高. 2.在订单表(order)中统计中,生 ...
- iOS webView的一些基本用法
1.自己拼接html来显示想要的文字(参考:http://www.mamicode.com/info-detail-492242.html) NSString *htmlStr=@"< ...
- Uva 10305 - Ordering Tasks 拓扑排序基础水题 队列和dfs实现
今天刚学的拓扑排序,大概搞懂后发现这题是赤裸裸的水题. 于是按自己想法敲了一遍,用queue做的,也就是Kahn算法,复杂度o(V+E),调完交上去,WA了... 于是检查了一遍又交了一发,还是WA. ...
- struts2 零配置
一.新建一个web项目,命名为:struts2 二.导入strut2所需的jar包 所需jar下载:http://pan.baidu.com/s/1dDxP4Z3 三.配置struts2的启动文件,在 ...
- Oracle基础(八) 数据完整性
一.数据完整性 数据完整性要求数据库中的数据具有准确性.准确性是通过数据库表的设计和约束来实现的.为了实现数据完整性,数据库需要做两方面的工作: 确保每行的数据符合要求. 确保每列的数据符合要求. 为 ...
- PHP output_buffering 你了解多少
一.我们要说一下php中的缓存大概有哪些! 在PHP中,我们可以粗略的将缓存分为客户端缓存(Browser缓存),服务器端缓存(Server缓存).由于PHP是基于B/S架构的,所以,我们可以理解为浏 ...