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 ...
随机推荐
- CMUSphinx Learn - Before you start
Before you start 开始之前 Before you start the development of the speech application, you need to consid ...
- 8.css内容移出与精灵图
定位的盒子居中显示 ★:margin:0 auto; 只能让标准流的盒子居中对齐. ★定位的盒子居中:先左右走父元素盒子的一半50%,在向左走子盒子的一半(margin-left:负值.) 标签包含 ...
- Jquery学习(表单-Button)-----jQuery1.4.2
<html> <head> <base href="<%=basePath%>"> <title>My JSP 'jqu ...
- CefSharp访问需要认证网页或接口(在Request的Headers中添加认证Token)
public class MyRequestHandler : DefaultRequestHandler { public static readonly string VersionNumberS ...
- C#实现枚举的相关操作
枚举中的Descript()描述值,以及枚举值是一种一一对应的关系.我们可以获取其描述值和枚举值,存放到字典中, 在实际的使用中我们就可以轻松的根据枚举值来获取其描述值,也可以通过枚举的描述值来获取其 ...
- 使用Charles对Android App的https请求进行抓包
本文背景 公司新项目要求抓取目前市面上一些热门App的数据,经过研究发现很多App的网络请求都使用https进行数据传输,这样问题就来了,http使用明文传输所有请求都能拦截到,而https请求无法拦 ...
- Python 一篇学会多线程
多线程和多进程是什么自行google补脑,廖雪峰官网也有,但是不够简洁,有点晕,所以就整个简单的范例. 对于python 多线程的理解,我花了很长时间,搜索的大部份文章都不够通俗易懂.所以,这里力图用 ...
- [海外干货] BlackHat 2017 首日议题的所有 PPT以及材料
今年是 Black Hat 举办的第 20 个年头,高温酷暑也挡不住全世界黑客和安全人员奔赴拉斯维加斯的热情.毕竟这可是一年一度的盛大狂欢啊.今年的 BHUSA 从美国东部时间时间 7 月 22 日( ...
- 在vue项目中stylus的安装及使用
Stylus是一个CSS预处理器. Stylus安装包安装: dell@DESKTOP-KD0EJ4H MINGW64 /f/gsff-frone $ cnpm install stylus --sa ...
- Python FTP文件传输
FTP Server import socket import struct from concurrent.futures import ThreadPoolExecutor import json ...