一、初始化方法

- (instancetype)initWithTitle:(NSString *)title delegate:(id<UIActionSheetDelegate>)delegate cancelButtonTitle:(NSString *)cancelButtonTitle destructiveButtonTitle:(NSString *)destructiveButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...;

参数说明:

title:视图标题

delegate:设置代理

cancelButtonTitle:取消按钮的标题

destructiveButtonTitle:特殊标记的按钮的标题

otherButtonTitles:其他按钮的标题

二、常用方法和属性介绍

@property(nonatomic,copy) NSString *title;

设置标题

@property(nonatomic) UIActionSheetStyle actionSheetStyle;

设置风格,枚举如下:

1
2
3
4
5
6
typedef NS_ENUM(NSInteger, UIActionSheetStyle) {
    UIActionSheetStyleAutomatic        = -1,      
    UIActionSheetStyleDefault          = UIBarStyleDefault,
    UIActionSheetStyleBlackTranslucent = UIBarStyleBlackTranslucent,
    UIActionSheetStyleBlackOpaque      = UIBarStyleBlackOpaque,
};

- (NSInteger)addButtonWithTitle:(NSString *)title;

添加一个按钮,会返回按钮的索引

- (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;

获取按钮标题

@property(nonatomic,readonly) NSInteger numberOfButtons;

获取按钮数量

@property(nonatomic) NSInteger cancelButtonIndex;

设置取消按钮的索引值

@property(nonatomic) NSInteger destructiveButtonIndex;

设置特殊标记

@property(nonatomic,readonly,getter=isVisible) BOOL visible;

视图当前是否可见

下面是几种弹出方式,会根据风格不同展现不同的方式

- (void)showFromToolbar:(UIToolbar *)view;

- (void)showFromTabBar:(UITabBar *)view;

- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated ;

- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated ;

- (void)showInView:(UIView *)view;

- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;

使用代码将视图收回

三、UIActionSheet代理方法

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;

点击按钮时触发的方法

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet;

视图将要弹出时触发的方法

- (void)didPresentActionSheet:(UIActionSheet *)actionSheet;

视图已经弹出式触发的方法

- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex;

点击按钮后,视图将要收回时触发的方法

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex;

点击按钮后,视图已经收回时触发的方法

最新文章

  1. Canvas——使用定时器模拟动态加载动画!
  2. maven构建简单的web项目
  3. 大漠绑定测试工具-VB6
  4. 三大WEB服务器对比分析(apache ,lighttpd,nginx)
  5. C#的惰性枚举
  6. simplify the design of the hardware forming the interface between the processor and thememory system
  7. 使用zookeeper实现分布式master选举(c 接口版本)
  8. HBase 3、HBase练习题
  9. Android报错:WindowManager$BadTokenException: Unable to add window -- window has already been added
  10. 伞兵(Paratroopers)
  11. mybatis 开发环境搭建
  12. DirectX11--深入理解与使用缓冲区资源
  13. socket编程初识
  14. 解决y7000笔记本ubuntu18.04下 休眠挂起后唤醒花屏
  15. Python基础(二)自定义函数
  16. 【IDEA&amp;&amp;Eclipse】3、IntelliJ IDEA 的 20 个代码自动完成的特性
  17. Java 一维数组作为参数和返回值
  18. JAVA基础之复识二
  19. css选择器思维导图
  20. myEtherWallet在线钱包的使用

热门文章

  1. BZOJ2288 【POJ Challenge】生日礼物 【堆 + 链表】
  2. 刷题总结——竞赛得分(ssoj)
  3. bzoj3743 [Coci2015]Kamp 常州模拟赛d6t2
  4. 单点登录跳转失败(原因是 主票据申请子票据失败) asp.net 同站点下不同应用间不同版本Framework问题
  5. poj 2318 向量的叉积二分查找
  6. AOP面向方面(切面)编程
  7. AtCoder Grand Contest 005F - Many Easy Problems
  8. 【索引】理解MySQL——索引与优化
  9. mongodb的入门学习
  10. android连数据库