UIKit 框架之UIActionSheet
UIAlertView和UIActionSheet相似,区别很小, 很容易理解。
// // ViewController.m // UIActionSheet // // Created by City--Online on 15/5/18. // Copyright (c) 2015年 XQB. All rights reserved. // #import "ViewController.h" @interface ViewController ()<UIActionSheetDelegate> @property(nonatomic,strong) UIActionSheet *actionSheet; @property(nonatomic,strong) UIActionSheet *actionSheet1; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; //设置Frame无效 _actionSheet=[[UIActionSheet alloc]initWithFrame:CGRectMake(20, 20, 200, 100)]; [_actionSheet addButtonWithTitle:@"相册"]; [_actionSheet addButtonWithTitle:@"相机"]; [_actionSheet addButtonWithTitle:@"取消"]; _actionSheet.cancelButtonIndex=2; _actionSheet.destructiveButtonIndex=1; _actionSheet.title=@"提示"; _actionSheet.delegate=self; // typedef NS_ENUM(NSInteger, UIActionSheetStyle) { // UIActionSheetStyleAutomatic = -1, // take appearance from toolbar style otherwise uses 'default' // UIActionSheetStyleDefault = UIBarStyleDefault, // UIActionSheetStyleBlackTranslucent = UIBarStyleBlackTranslucent, // UIActionSheetStyleBlackOpaque = UIBarStyleBlackOpaque, // }; _actionSheet.actionSheetStyle=UIActionSheetStyleBlackOpaque; _actionSheet.tag=10001; NSLog(@"firstOtherButtonIndex=%ld",_actionSheet.firstOtherButtonIndex); for (int i=0; i<_actionSheet.numberOfButtons; i++) { NSLog(@"i=%d %@",i,[_actionSheet buttonTitleAtIndex:i]); } [_actionSheet showInView:self.view]; _actionSheet1 =[[UIActionSheet alloc]initWithTitle:@"提示" delegate:self cancelButtonTitle:@"NO" destructiveButtonTitle:@"DestructiveButton" otherButtonTitles:@"YES", nil]; _actionSheet1.tag=10002; for (int i=0; i<_actionSheet1.numberOfButtons; i++) { NSLog(@"i=%d %@",i,[_actionSheet1 buttonTitleAtIndex:i]); } [_actionSheet1 showInView:self.view]; } //UIActionSheetDelegate - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (actionSheet.tag==10001) { NSString *title=[_actionSheet buttonTitleAtIndex:buttonIndex]; NSLog(@"我点击了: %@",title); } else { if (buttonIndex==2) { [_actionSheet dismissWithClickedButtonIndex:2 animated:YES]; } } } //以下这些和UIAlertView的相似 - (void)actionSheetCancel:(UIActionSheet *)actionSheet { NSLog(@"actionSheetCancel"); } - (void)willPresentActionSheet:(UIActionSheet *)actionSheet { NSLog(@"willPresentActionSheet"); } - (void)didPresentActionSheet:(UIActionSheet *)actionSheet { NSLog(@"didPresentActionSheet"); } - (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex { NSLog(@"willDismissWithButtonIndex"); } - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex { NSLog(@"didDismissWithButtonIndex"); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
UIKit 框架之UIActionSheet的更多相关文章
- UIKit框架使用总结--看看你掌握了多少
一.经常使用的,基本就是每次项目迭代都需要使用的 UIView.UILabel.UIImage.UIColor.UIFont.UIImageView.UITextField.UIButton. UIS ...
- Swift - 重写UIKit框架类的init初始化方法(以UITabBarController为例)
原来写了篇文章讲UITabBarController的用法,当时是从UIViewController跳转到UITabBarController页面,代码如下: 1 self.presentViewCo ...
- UIKit框架
在今后的应用程序构建中,会陆续使用各式各样的控件,因此UIKit框架的引入是必不可少的! 一.简介 UIKitk框架提供一系列的Class(类)来建立和管理iPhone OS应用程序的用户界面接口.应 ...
- iOS学习32之UIKit框架-可视化编程-XIB
1. Interface Builder 可视化编程 1> 概述 GUI : 图形用户界面(Graphical User Interface, 简称GUI, 又称图形化界面) 是指采用图形方式显 ...
- 基础框架Fundation和UIkit框架的定义和使用
Foundation 框架为所有应用程序提供基本的系统服务 您的应用程序以及 UIKit 和其他框架,都建立在 Foundation 框架的基础结构之上.Foundation 框架提供许多基本的对象类 ...
- iOS开发概述UIkit动力学,讲述UIKit的Dynamic特性,UIkit动力学是UIkit框架中模拟真实世界的一些特性。
转发:http://my.oschina.net/u/1378445/blog/335014 iOS UIKit动力学 Dynamics UIAttachmentBehavior 实现iMessage ...
- iOS开发UIKit框架-可视化编程-XIB
1. Interface Builder 可视化编程 1> 概述 GUI : 图形用户界面(Graphical User Interface, 简称GUI, 又称图形化界面) 是指采用图形方式显 ...
- 79、iOS 的Cocoa框架、Foundation框架以及UIKit框架
Cocoa框架是iOS应用程序的基础 1. Cocoa是什么? Cocoa是 OS X和ios 操作系统的程序的运行环境. 是什么因素使一个程序成为Cocoa程序呢?不是编程语言,因为在Cocoa开发 ...
- UIKit 框架之UIView二
下面这些都是UIView一些基本的东西,具体的可以参考UIKit 框架之UIView一博客 一.自定义一个View // // MyView.m // UIView // // Created by ...
随机推荐
- CSS 基础 例子 盒子模型及外边距塌陷
我们通常设置的宽度和高度,是指盒子模型中内容(content)的宽度和高度.元素的高度,还要加上上下padding和上下border,元素整个盒子的高度还要加上上下margin:宽度类似计算. 注意: ...
- Brain Rules: 12 Principles for Surviving and Thriving at Work, Home, and School
选自 https://litemind.com/brain-rules/
- 关于 Keil uVision2 中文注释会显示不完整,字体不正常的问题
在Keil中添加中文注释经常出现这样情况: ,注释文字不正常! 解决方案:Edit---->Option----->选择color&fonts选项卡中的Editor c Files ...
- Oracle开发包被锁解决办法-终极办法
http://www.itpub.net/forum.php?mod=viewthread&tid=1761963 以前在数据库维护中,基本都是碰到表被锁的情况,然后就是查找被锁的表相关的信息 ...
- bootstrap基础学习小记(三)网格简介
网格系统:网格系统的实现原理非常简单,仅仅是通过定义容器大小,平分12份(也有平分成24份或32份,但12份是最常见的),再调整内外边距,最后结合媒体查询,就制作出了强大的响应式网格系统.Bootst ...
- OSLab文件描述符
日期:2019/3/24 内容:Linux文件描述符. 一.基本概念 文件描述符(File Descriptor) 一个非负整数.应用程序利用文件描述符来访问文件.打开现存文件或新建文件时,内 ...
- Deque(队列)
目录 Deque 概述 特点 常用方法 双向队列操作 ArrayDeque Deque 概述 一个线性 collection,支持在两端插入和移除元素.名称 deque 是"double e ...
- SQL高效查询两个表不同的数据
逻辑相对复杂,但是速度最快: )
- gulp的安装以及使用详解,除了详细还是详细
安装gulp: 1. 创建本地包管理环境: 使用npm init命令在本地生成一个package.json文件,package.json是用来记录你当前这个项目依赖了哪些包,以后别人拿到你这个项目后, ...
- Linux CPU实时监控工具
注:ubuntu需要安装sysstat: sudo apt install sysstat [root@testDb ~]# mpstat 1 10 ---显示操作系统内核版本 以及硬件配置 ...