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

首頁 > 學院 > 開發(fā)設計 > 正文

IOS中的三種彈窗模式

2019-11-14 18:56:16
字體:
來源:轉載
供稿:網友

#PRagma mark 方法1

/**

 *  用在IOS7,用到了代理

 */

- (void)use1

{

    // 1.創(chuàng)建一個中間彈框,有取消確定按鈕,設置代理為當前控制器,由控制器監(jiān)聽點擊了“取消”還是“確定”按鈕

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"點擊了圖片按鈕" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];

    

    // 2.顯示在屏幕上

    [alert show];

}

#pragma mark 監(jiān)聽方式1中出現(xiàn)的彈框中的按鈕點擊,控制器來監(jiān)聽點擊了取消還是確定按鈕

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

    // 默認取消按鈕索引為0

    if (buttonIndex == 0) NSLog(@"點擊了取消按鈕");

    else NSLog(@"點擊了確定按鈕");

}

 

#pragma mark 方法2

/**

 *  用在IOS8,沒有代理。點擊按鈕時要執(zhí)行的操作放在了block中,因此不需要設置代理

 */

- (void)use2

{

    // 1.創(chuàng)建彈框控制器, UIAlertControllerStyleAlert這個樣式代表彈框顯示在屏幕中央

    UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"提示" message:@"點擊了頭像" preferredStyle:UIAlertControllerStyleAlert];

 

    // 2.添加取消按鈕,block中存放點擊了取消按鈕要執(zhí)行的操作

   UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

        NSLog(@"點擊了取消按鈕");

    }];

    UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

        NSLog(@"點擊了確定按鈕");

    }];

    // 3.取消確定按鈕加入到彈框控制器中

    [alertVc addAction:cancle];

    [alertVc addAction:confirm];

    

    // 4.控制器 展示彈框控件,完成時不做操作

    [self presentViewController:alertVc animated:YES completion:^{

        nil;

    }];

}

 

#pragma mark 方法3

/**

 *  用在IOS8,沒有用到代理。跟方式2唯一不同的是:彈框的樣式變?yōu)?span id="70qarhlowxag" class="s1">“UIAlertControllerStyleActionSheet”, 彈框出現(xiàn)在屏幕底部

 */

- (void)use3

{

    UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"提示" message:@"點擊了頭像" preferredStyle:UIAlertControllerStyleActionSheet];

    UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

        NSLog(@"點擊了取消");

    }];

    UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

        NSLog(@"點擊了確定按鈕");

    }];

    [alertVc addAction:cancle];

    [alertVc addAction:confirm];

    

    [self presentViewController:alertVc animated:YES completion:^{

        nil;

    }];

}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 香蕉国产在线视频 | 亚州综合网 | 一本色道久久综合狠狠躁篇适合什么人看 | 国产精品一区在线观看 | 亚洲乱操 | 久久91亚洲人成电影网站 | 亚洲一区二区国产 | 精品一区二区电影 | av影院在线播放 | 毛片在线播放视频 | 欧美日韩在线播放 | 欧美一区二区网站 | 日本在线观看一区二区 | 在线观看免费污视频 | 久久久久国产成人精品亚洲午夜 | 韩国一级免费视频 | 91美女啪啪 | 久久精品中文 | 黄色片网站在线播放 | 99re热精品视频 | h视频免费看 | 九九热精品视频在线 | 精品一区久久久 | 视频一区二区三区免费观看 | 欧美成人免费在线视频 | 国产成人免费精品 | 免费日韩片 | 又黄又爽又色无遮挡免费 | 国产一国产精品一级毛片 | 成人啪啪18免费网站 | 天天碰夜夜操 | 在线成人免费网站 | 国产免费一区视频 | 欧美人成在线视频 | 久久逼逼 | 日本aaa一级片 | 免费亚洲视频在线观看 | 黄色小视频在线免费看 | 国产成人小视频在线观看 | 成人午夜一区 | 免费a级片视频 |