国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

常用的iOS中表單按鈕選項UIActionSheet的使用方法

2020-02-19 15:47:58
字體:
來源:轉載
供稿:網友

iOS開發中經常使用UI操作表,但默認情況下只能添加按鈕,今天武林技術頻道網為大家帶來常用的iOS中表單按鈕選項UIActionSheet的使用方法,感興趣的朋友一起進入下文了解一下吧!

什么是操作表單?看圖:

201661691629084.gif (355×703)

一看圖就明白了,毋需多說。

?

UIActionSheet* mySheet = [[UIActionSheet alloc]?
?????????????????????????? initWithTitle:@"ActionChoose"??
?????????????????????????? delegate:self??
?????????????????????????? cancelButtonTitle:@"Cancel"?
?????????????????????????? destructiveButtonTitle:@"Destroy"?
?????????????????????????? otherButtonTitles:@"OK", nil];?
??? [mySheet showInView:self.view];?


與UIAlertView類似,我們也是在委托方法里處理按下按鈕后的動作。記得在所委托的類加上UIActionSheetDelegate。

?

?

?


- (void)actionSheetCancel:(UIActionSheet *)actionSheet{?
??? //?
}?
- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{?
??? //?
}?
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{?
??? //?
}?
-(void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex{?
??? //?
}?


看到那個紅色的按鈕沒?那是ActionSheet支持的一種所謂的銷毀按鈕,對某戶的某個動作起到警示作用,
比如永久性刪除一條消息或者日志。如果你指定了一個銷毀按鈕他就會以紅色高亮顯示:

?

?

?


mySheet.destructiveButtonIndex=1;?


與導航欄類似,操作表單也支持三種風格 :

?

?

?


UIActionSheetStyleDefault????????????? //默認風格:灰色背景上顯示白色文字?
UIActionSheetStyleBlackTranslucent???? //透明黑色背景,白色文字?
UIActionSheetStyleBlackOpaque????????? //純黑背景,白色文字?


用法用例:

?

?

?


mySheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;

?

?

常用方法和屬性

顯示ActionSheet方法:
1.在一個視圖內部顯示,可以用showInView

?

[mySheet showInView:self];


2.如果要將ActonSheet 與工具欄或者標簽欄對齊,可以使用showFromToolBar或showFromTabBar

?

?

?


[mySheet showFromToolBar:toolbar];
[mySheet showFromTabBar:tabbar];

?

解除操作表單
用戶按下按鈕之后,Actionsheet就會消失——除非應用程序有特殊原因,需要用戶按下做個按鈕。用dismiss方法可令表單消失:

?

[mySheet dismissWithClickButtonIndex:1 animated:YES];?
@property(nonatomic,copy) NSString *title;

?

設置標題

?

@property(nonatomic) UIActionSheetStyle actionSheetStyle;

?

添加一個按鈕,會返回按鈕的索引

?

?

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


[/code]

?

獲取按鈕標題

?

- (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;


點擊按鈕后,視圖已經收回時觸發的方法

以上是關于常用的iOS中表單按鈕選項UIActionSheet的使用方法,相信大家都了解了,想要學習更多專業知識,請繼續關注武林技術頻道!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 达日县| 任丘市| 北宁市| 山阴县| 灵武市| 岫岩| 天等县| 东山县| 榆树市| 衡水市| 新津县| 安陆市| 苏尼特右旗| 井冈山市| 垫江县| 阜平县| 阿拉善右旗| 饶平县| 麻城市| 板桥市| 龙门县| 涿鹿县| 玉山县| 庆城县| 永春县| 金山区| 吉水县| 个旧市| 阜康市| 青海省| 延庆县| 宁陕县| 涞水县| 玉门市| 宁乡县| 台东市| 招远市| 武鸣县| 湾仔区| 黄陵县| 金塔县|