iOS UIAlertView自動(dòng)關(guān)閉功能
一,效果圖。
二,代碼。
RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController : UIViewController <UIAlertViewDelegate> @end RootViewController.m - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //alert UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"一個(gè)可以自動(dòng)關(guān)閉的Alert窗口" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil]; [alert show]; //顯示框 UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; indicator.backgroundColor=[UIColor redColor]; indicator.center = CGPointMake(alert.bounds.size.width/2, alert.bounds.size.height-40.0); [indicator startAnimating]; [alert insertSubview:indicator atIndex:0]; //定時(shí)器 [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(dismissAlert:) userInfo:[NSDictionary dictionaryWithObjectsAndKeys:alert, @"alert", @"testing ", @"key" ,nil] repeats:NO]; } //alert 自動(dòng)消失 -(void) dismissAlert:(NSTimer *)timer{ UIAlertView *alert = [[timer userInfo] objectForKey:@"alert"]; [alert dismissWithClickedButtonIndex:0 animated:YES]; }
以上所述是小編給大家介紹的iOS UIAlertView自動(dòng)關(guān)閉,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
iOS動(dòng)畫(huà)特效之立方體翻轉(zhuǎn)
今天起為大家?guī)?lái)iOS動(dòng)畫(huà)特效合集之立方體翻轉(zhuǎn),APP如美女,動(dòng)畫(huà)如衣裳,趕緊為她披上漂亮的衣裝吧!2016-08-08iOS開(kāi)發(fā)使用JSON解析網(wǎng)絡(luò)數(shù)據(jù)
JSON是一種輕量級(jí)的數(shù)據(jù)格式,一般用于數(shù)據(jù)交互,服務(wù)器返回給客戶(hù)端的數(shù)據(jù),一般都是JSON格式或者XML格式(文件下載除外)下面我們就看下在IOS開(kāi)發(fā)中如何結(jié)合json呢2016-02-02iOS應(yīng)用開(kāi)發(fā)中UIView添加邊框顏色及設(shè)置圓角邊框的方法
這篇文章主要介紹了iOS應(yīng)用開(kāi)發(fā)中UIView添加邊框顏色及設(shè)置圓角邊框的方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2016-02-02IOS打開(kāi)照相機(jī)與本地相冊(cè)選擇圖片實(shí)例詳解
這篇文章主要介紹了IOS打開(kāi)照相機(jī)與本地相冊(cè)選擇圖片實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2017-06-06iOS自定義雷達(dá)掃描擴(kuò)散動(dòng)畫(huà)
這篇文章主要為大家詳細(xì)介紹了iOS自定義雷達(dá)掃描擴(kuò)散動(dòng)畫(huà),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-10-10iOS實(shí)現(xiàn)MJRefresh下拉刷新(上拉加載)使用詳解
本篇文章主要介紹了iOS實(shí)現(xiàn)MJRefresh下拉刷新(上拉加載)使用詳解,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-01-01