IOS中UIActionSheet使用方法详解
2015-08-08 15:15
477 查看
一、初始化方法
- (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;
设置风格,枚举如下:
?
添加一个按钮,会返回按钮的索引
- (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;
点击按钮后,视图已经收回时触发的方法
相关文章推荐
- 手机开发之H5+规范的原生UI警示框
- UITextField
- 2015多校第四场1003 hdu 5329 Question for the Leader
- Android编译failed to find Build Tools revision 23.0.0 rc2解决
- UITableView控件使用总结
- String.valueOf传null参数的不同表现
- 解决“同一UIView中有多个UITableView时点击状态栏不能置顶”问题
- UIButton的实现(含有边框)
- iOS 中 UITextView 限制最大输入字数
- iOS开发UIScrollView常见属性和方法
- iOS UI控件之间的关系图
- iOS中UIPickerView常见属性和方法的总结
- iOS 使用纯代码自定义UITableViewCell实现一个简单的微博界面布局
- [leedcode 225] Implement Stack using Queues
- HDOJ Guess the number 3337【神题-抓取杭电后台输出数据】
- iOS UITableView数据刷新
- iOS 并发编程之 Operation Queues
- iOS第三方做滤镜最主流的开源框架GPUImage
- SequenceFile类
- Lazy懒加载(延迟加载)UITableView