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 ...
随机推荐
- 一些仪器的解码程序(delphi)
http://www.jiandande.com/html/ITzixun-jishu/Lisyanjiuyuan/2013/0204/1600_3.html 看了后觉得不错,可能有需要的 ----- ...
- Azure DevOps Server(TFS 2019) 中的SonarQube扫描任务出现错误:AppTest.java can't be indexed twice
SonarQube错误描述 将一个Maven示例程序导入到Azure DevOps的待库中,执行SonarQube扫描过程时, DevOps Server提示下面的错误信息: [ERROR] Fail ...
- 统计--VARCHAR与NVARCHAR在统计预估上的区别
最近遇到一个问题,当查询使用到模糊查询时,由于预估返回行数过高,执行计划认为索引查找+Key Lookup的成本过高,因此采用Clustered Index Scan的方式,消耗大量逻辑IO,执行计划 ...
- 什么是PAGELATCH和PAGEIOLATCH
在分析SQL server 性能的时候你可能经常看到 PAGELATCH和PAGEIOLATCH.比方说 Select * from sys.dm_os_wait_stats 的输出里面就有Latch ...
- [机翻] WIRER ON THE WIRE - SIGNALR协议的非正式描述
原文 原文很简单,以下为机翻 WIRER ON THE WIRE - SIGNALR协议的非正式描述 我已经看到询问有关SignalR协议的描述的问题出现了很多.哎呀,当我开始关注SignalR时,我 ...
- 如何将Skyline66嵌入WPF中
1.新建WPF项目: 2.添加引用 .net引用:System.Windows.Forms和WindowsFormsIntegration skyline引用:AxInterop.TerraExplo ...
- C语言Socket-单工通信(客户端向服务器发送数据)
服务端(server) #include <stdio.h> #include <winsock2.h> #pragma comment(lib,"ws2_32.li ...
- Dubbo实现原理之基于SPI思想实现Dubbo内核
dubbo中SPI接口的定义如下: @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public ...
- Swift 里 Set(四)Testing for Membership
即contains操作 /// - Parameter member: An element to look for in the set. /// - Returns: `true` if `mem ...
- 记录cacl()函数中使用scss变量不生效的问题
问题 使用cacl()动态计算元素的高度,运算中包含一个scss变量.如下: height: calc(100% - $ws-header-height); 在浏览器中发现并没有达到预期效果,scss ...