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 ...
随机推荐
- php 换行 空格分割处理
<?php function parse_specification($specification){ $rt=array(); $lines=array_filter(preg_split(& ...
- Docker 底层实现
基本架构 Docker 采用了 C/S架构,包括客户端和服务端. Docker daemon 作为服务端接受来自客户的请求,并处理这些请求(创建.运行.分发容器). 客户端和服务端既可以运行在一个机器 ...
- Youth(青春)
Youth is not a time of life; it is a state of mind; it is not a matter of rosy cheeks, red lips and ...
- Linux分区有损坏修复
如果Linux分区有损坏情况,启动有问题,不能正常进入文本或图形界面.那么一般会出现提示,需要输入Root密码登录后采用fsck -t ext3 -r /usr/local 修复 , /usr/loc ...
- 【阿里云产品公测】阿里云OpenSearch初次使用评测
作者:阿里云用户 bailimei 从一开始我就对opensearch非常陌生,这是我第一次接触它,本以为对我来说上手难度会比较大,看完帮助信息后我决定试用看看,经试用后我发现阿里云opensearc ...
- Debian 8 安装 Nvidia 显卡驱动
sudo apt-get install linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,') nvidia-kernel-dkms 正在读取软件包列表.. ...
- 自定义EditText实现一键删除数据
转载请注明出处http://blog.csdn.net/xiaanming/article/details/11066685 自定义EditText带删除小图标, 实现的功能: 点击删除小图标,删除当 ...
- amoeba实现MySQL读写分离
amoeba实现MySQL读写分离 准备环境:主机A和主机B作主从配置,IP地址为192.168.131.129和192.168.131.130,主机C作为中间件,也就是作为代理服务器,IP地址为19 ...
- HTML <input> 标签的 maxlength 属性
前端的表单,需要进行验证. 结合JS表单验证框架,写了很多前端验证的代码. 其中,有这么一个需求:用户最多只能输入10个字符. 按照惯性,肯定是会去写JS表单验证了. 实际上,根本没有必要. HTML ...
- ionic Modal
在ionic中,modal也是添加控制器写服务的~ 在modal.html页面中增加控制器:ng-controller="aboutCtrl"记住要给这个添加控制器.头部使其关闭按 ...