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 ...
随机推荐
- 数组中超过N分之一的数字
寻找数组中超过一半的元素,这是一道十分经典和普遍的面试题了,实现起来比较容易,只是需要写技巧,将问题扩展就可以衍生到求数组中几个超过N分一的元素,例如找出数组中3个出现次数超过1/4的元素. /*** ...
- HDU 1556 区间查询
Color the ball Time Limit: 3000 MS Memory Limit: 32768 KB 64-bit integer IO format: %I64d , %I64u Ja ...
- ReportMachine OCX 的使用方法
ReportMachine OCX http://rmachine.haotui.com/thread-55-1-1.html RMReport.ocx RMEngine.Init(1); // 初始 ...
- C#基础——C#中问号的使用
1. 可空类型修饰符(?): 引用类型可以使用空引用表示一个不存在的值,而值类型通常不能表示为空. 例如:string str=null; 是正确的,int i=null; 编译器就会报错. 为了使值 ...
- netcore的NLog使用小记
1. 启动应用程序日志配置 修改Program.cs,在WebHostBuilder构建时配置日志 public static IWebHostBuilder CreateWebHostBuilder ...
- padding(内边框), border(边框), margin, 标准文档流, 块级元素和行内元素, 浮动 ,margin的用法
盒模型 在CSS中,"box model"这一术语是用来设计和布局时使用,然后在网页中基本上都会显示一些方方正正的盒子.我们称为这种盒子叫盒模型. 盒模型有两种:标准模型和IE模型 ...
- Git - 必知必会
配置Git git config --global user.name "your_name" # 配置全局用户名 git config --global user.email & ...
- SQL 将一列多行数据合并为一行
原表数据: 期望结果: 使用STUFF + FOR XML PATH即可实现以上效果 执行以下SQL: , , '') AS Course FROM Student AS T 可以看到输出结果与期望结 ...
- 一步步Cobol 400上手自学入门教程04 - 过程部
过程部的作用:编写程序要执行的语句,是程序的核心. 结构: 基本语句 INITIALIZE 设置数据项的初始值 ACCEPT 接收从键盘或指定设备上获得输入数据. 例子: 当批处理文件读到调用ACCP ...
- django views视图函数返回值 return redirect httpresponse总结
django views视图函数返回值 return redirect render httpresponse总结