UIActionSheet简介
来源:互联网 发布:豆荚网络加速器破解 编辑:程序博客网 时间:2024/04/28 18:32
UIActionSheet是弹出的按钮选项。
创建:
1.初始化:
- (instancetype)initWithTitle:(NSString *)title delegate:(id<UIActionSheetDelegate>)delegate cancelButtonTitle:(NSString *)cancelButtonTitle destructiveButtonTitle:(NSString *)destructiveButtonTitle otherButtonTitles:(NSString *)otherButtonTitlestitle为弹出框的标题,delegate设置按钮被触摸时相应的委托类,cancelButtonTitle是取消按钮,destructiveButtonTitle是红色按钮,otherButtonTitles是你想设置的其他按钮,使用数组。
设置属性:
2.设置按钮被触摸时相应的委托代理类:
@property(nonatomic, assign) id< UIActionSheetDelegate > delegate
3.在标题栏显示的字符串:
@property(nonatomic, copy) NSString *title
4.是否显示:
@property(nonatomic, readonly, getter=isVisible) BOOL visible
5.显示风格:
@property(nonatomic) UIActionSheetStyle actionSheetStyle
typedef enum { UIActionSheetStyleAutomatic = -1, UIActionSheetStyleDefault = UIBarStyleDefault, UIActionSheetStyleBlackTranslucent = UIBarStyleBlackTranslucent, UIActionSheetStyleBlackOpaque = UIBarStyleBlackOpaque,} UIActionSheetStyle;
配置按钮:
6.添加自定义按钮:
- (NSInteger)addButtonWithTitle:(NSString *)title
7.按钮数量:
@property(nonatomic, readonly) NSInteger numberOfButtons
8.根据索引,返回指定按钮的标题:
- (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex
9.取消按钮的索引:
@property(nonatomic) NSInteger cancelButtonIndex
10.红色高亮按钮的索引:
@property(nonatomic) NSInteger destructiveButtonIndex
11.第一个自定义按钮的索引:
@property(nonatomic, readonly) NSInteger firstOtherButtonIndex
呈现:
12.显示在标签条中:
- (void)showFromTabBar:(UITabBar *)view
13.显示在工具条中:
- (void)showFromToolbar:(UIToolbar *)view
14.显示在视图中:
- (void)showInView:(UIView *)view
15.在指定的按钮item显示:
- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated
16.显示在指定视图:
- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated
解除:
17.立即解除(隐藏):
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
UIActionSheetDelegate:
应对措施:
1.触摸操作表中的任意按钮是触发:
- (void)actionSheet:(UIActionSheet *)actionSheetclickedButtonAtIndex:(NSInteger)buttonIndex此方法比4先调用。
定制行为:
2.操作表显示前被调用:
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
3.操作表显示后被调用:
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet
4.操作表被关闭前调用:
- (void)actionSheet:(UIActionSheet *)actionSheetwillDismissWithButtonIndex:(NSInteger)buttonIndex
5.操作表关闭后被调用:
- (void)actionSheet:(UIActionSheet *)actionSheetdidDismissWithButtonIndex:(NSInteger)buttonIndex操作表显示中应用程序进入睡眠状态也会被调用。
取消:
6.取消:
- (void)actionSheetCancel:(UIActionSheet *)actionSheet
0 0
- UIActionSheet简介
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet
- UIActionSheet 用法
- FPGA和opencl之altera soc 开发1
- 学习感悟
- UNIX发展历史以及发行版本
- No permission to write APN settings: Neither user 10047 nor current process has android.permission.W
- 春节出现过敏的现象是我们患者躲不过的宿命
- UIActionSheet简介
- Android下拉刷新的实现
- MFC六大核心机制之三:动态创建
- 自定义cocos2dx的层与精灵
- ios Sqlite数据库增删改查基本操作
- 酒糟鼻治疗需合理
- MFC六大核心机制之二:运行时类型识别(RTTI)
- MINA源码分析---协议编码器 ProtocolEncoder
- MFC六大核心机制之一:MFC程序的初始化