IOS 中彈框的實(shí)現(xiàn)方法整理
IOS 中彈框的實(shí)現(xiàn)方法整理
#define iOS8Later ([UIDevice currentDevice].systemVersion.doubleValue >= 8.0)
ios 8以前的彈框
@interface RootViewController ()<UIAlertViewDelegate> @end
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"登陸失敗" message:@"請(qǐng)重新輸入用戶名和密碼" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil]; [alert show];
#pragma mark - UIAlertView Delegate Methods - - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if(buttonIndex == 0) { NSLog(@"點(diǎn)擊取消按鈕后,想要的操作,可以加此處"); } else if(buttonIndex == 1) { NSLog(@"點(diǎn)擊確定按鈕后,想要的操作,可以加此處"); } }
ios8以后的彈框
UIAlertController *_alertVC = [UIAlertController alertControllerWithTitle:@"登陸失敗" message:@"請(qǐng)重新輸入用戶名和密碼" preferredStyle:UIAlertControllerStyleAlert]; //警告類型,紅色字體 UIAlertActionStyleDestructive // UIAlertAction *_doAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDestructive handler:nil]; // [_alertVC addAction:_doAction]; UIAlertAction *_doAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { NSLog(@"點(diǎn)擊確定按鈕后,想要的操作,可以加此處"); }]; [_alertVC addAction:_doAction]; // UIAlertAction *_cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]; // [_alertVC addAction:_cancleAction]; UIAlertAction *_cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { NSLog(@"點(diǎn)擊取消按鈕后,想要的操作"); }]; [_alertVC addAction:_cancleAction]; [self presentViewController:_alertVC animated:YES completion:nil];
//警告類型,紅色字體 UIAlertActionStyleDestructive,如下圖所示的效果 UIAlertAction *_doAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDestructive handler:nil]; [_alertVC addAction:_doAction];
如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,希望通過(guò)本文能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
iOS開(kāi)發(fā)中實(shí)現(xiàn)一個(gè)簡(jiǎn)單的圖片瀏覽器的實(shí)例講解
這篇文章主要介紹了iOS開(kāi)發(fā)中實(shí)現(xiàn)一個(gè)簡(jiǎn)單的圖片瀏覽器的實(shí)例講解,代碼基礎(chǔ)傳統(tǒng)的Objective-C,需要的朋友可以參考下2016-01-01解決ios端點(diǎn)擊按鈕閃爍問(wèn)題(小tips)
這篇文章主要介紹了ios端點(diǎn)擊按鈕閃爍的解決方法(小tips),需要的朋友參考下吧2017-10-10Mac OSX 打開(kāi)原生自帶讀寫NTFS功能(圖文)
這篇文章主要介紹了Mac OSX 打開(kāi)原生自帶讀寫NTFS功能(圖文),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11ios App加載本地HTML網(wǎng)頁(yè),點(diǎn)擊網(wǎng)頁(yè)鏈接跳轉(zhuǎn)到app頁(yè)面的方法
下面小編就為大家分享一篇ios App加載本地HTML網(wǎng)頁(yè),點(diǎn)擊網(wǎng)頁(yè)鏈接跳轉(zhuǎn)到app頁(yè)面的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-01-01iOS實(shí)現(xiàn)app間跳轉(zhuǎn)功能
這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)app間跳轉(zhuǎn)功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05iOS中使用UISearchBar控件限制輸入字?jǐn)?shù)的實(shí)現(xiàn)方法
這篇文章主要介紹了iOS中使用UISearchBar控件限制輸入字?jǐn)?shù)的實(shí)現(xiàn)方法的相關(guān)資料,需要的朋友可以參考下2016-08-08iOS使用UICountingLabel實(shí)現(xiàn)數(shù)字變化的動(dòng)畫效果
本文主要介紹了iOS使用UICountingLabel實(shí)現(xiàn)數(shù)字變化動(dòng)畫效果的方法,具有一定的參考價(jià)值,下面跟著小編一起來(lái)看下吧2016-12-12