麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

(轉(zhuǎn))UIALertView的基本用法與UIAlertViewDelegate對(duì)對(duì)話框的事件處理方法

2019-11-14 19:22:23
字體:
供稿:網(wǎng)友
首先,視圖控制器必須得實(shí)現(xiàn)協(xié)議UIAlertViewDelegate中的方法,并指定delegate為self,才能使彈出的Alert窗口響應(yīng)點(diǎn)擊事件。具體代碼如下:
#import <UIKit/UIKit.h>@interface ViewController : UIViewController<UIAlertViewDelegate>@end

ViewController.m中的詳細(xì)代碼:

- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view from its nib        //初始化AlertView    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"AlertViewTest"                                                   message:@"message"                                                  delegate:self                                         cancelButtonTitle:@"Cancel"                                         otherButtonTitles:@"OtherBtn",nil];    //設(shè)置標(biāo)題與信息,通常在使用frame初始化AlertView時(shí)使用    alert.title = @"AlertViewTitle";    alert.message = @"AlertViewMessage";        //這個(gè)屬性繼承自UIView,當(dāng)一個(gè)視圖中有多個(gè)AlertView時(shí),可以用這個(gè)屬性來區(qū)分    alert.tag = 0;    //只讀屬性,看AlertView是否可見    NSLog(@"%d",alert.visible);    //通過給定標(biāo)題添加按鈕    [alert addButtonWithTitle:@"addButton"];    //按鈕總數(shù)    NSLog(@"number Of Buttons :%d",alert.numberOfButtons);    //獲取指定索引的按鈕標(biāo)題    NSLog(@"buttonTitleAtIndex1:%@",[alert buttonTitleAtIndex:1]);    NSLog(@"buttonTitleAtIndex2:%@",[alert buttonTitleAtIndex:2]);    //獲取取消按鈕的索引    NSLog(@"cancelButtonIndex:%d",alert.cancelButtonIndex);    //獲取第一個(gè)其他按鈕的索引    NSLog(@"firstOtherButtonIndex:%d",alert.firstOtherButtonIndex);    //顯示AlertView    [alert show];    [alert release];}#PRagma marks -- UIAlertViewDelegate --//根據(jù)被點(diǎn)擊按鈕的索引處理點(diǎn)擊事件-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{    NSLog(@"clickButtonAtIndex:%d",buttonIndex);}//AlertView已經(jīng)消失時(shí)執(zhí)行的事件-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{    NSLog(@"didDismissWithButtonIndex");}//ALertView即將消失時(shí)的事件-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex{    NSLog(@"willDismissWithButtonIndex");}//AlertView的取消按鈕的事件-(void)alertViewCancel:(UIAlertView *)alertView{    NSLog(@"alertViewCancel");}//AlertView已經(jīng)顯示時(shí)的事件-(void)didPresentAlertView:(UIAlertView *)alertView{    NSLog(@"didPresentAlertView");}//AlertView即將顯示時(shí)-(void)willPresentAlertView:(UIAlertView *)alertView{    NSLog(@"willPresentAlertView");}- (void)viewDidUnload{    [super viewDidUnload];    // Release any retained subviews of the main view.    // e.g. self.myOutlet = nil;}

 


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 蜜桃视频网站在线观看 | 欧美 日韩 三区 | 国产xxxx岁13xxxxhd | 一级免费 | 亚洲一二区精品 | 久久久久久久久久久久久久久伊免 | 91快色视频 | 久久精品一二三区白丝高潮 | 国产午夜免费福利 | 黄色毛片a级 | 一级黄色播放 | 污污短视频 | 亚洲免费网站 | 免费日本一区二区 | 综合激情网 | 日本中文字幕久久 | 97综合 | 一区二区久久精品66国产精品 | 激情综合网俺也去 | 黑人操穴| 爽爽淫人综合网网站 | 久久精品美乳 | 成年免费视频黄网站在线观看 | 国产一级毛片视频在线! | 黄色大片在线免费观看 | 蜜桃视频最新网址 | av电影在线观看网址 | 精品一区二区三区毛片 | 美女污污视频在线观看 | 欧美成人视 | 狠狠一区| 久久毛片免费观看 | 国产高潮国产高潮久久久91 | 蜜桃视频最新网址 | 欧美中文字幕一区二区 | 欧美一级淫片免费视频1 | 久久久久国产一区二区三区不卡 | av国产在线被下药迷网站 | 亚洲成人在线视频网 | 日韩精品中文字幕一区二区 | 91精品观看91久久久久久国产 |