iOS UIAlertView自動關(guān)閉功能
更新時間:2017年06月20日 11:10:18 作者:弦外雨
這篇文章主要介紹了iOS UIAlertView自動關(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:@"一個可以自動關(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];
//定時器
[NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(dismissAlert:) userInfo:[NSDictionary dictionaryWithObjectsAndKeys:alert, @"alert", @"testing ", @"key" ,nil] repeats:NO];
}
//alert 自動消失
-(void) dismissAlert:(NSTimer *)timer{
UIAlertView *alert = [[timer userInfo] objectForKey:@"alert"];
[alert dismissWithClickedButtonIndex:0 animated:YES];
}
以上所述是小編給大家介紹的iOS UIAlertView自動關(guān)閉,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
iOS實現(xiàn)UIScrollView的無限輪播功能(原理)詳解
在現(xiàn)在的一些App中常常見到圖片輪播器,一般用于展示廣告、新聞等數(shù)據(jù),下面這篇文章主要給大家介紹了關(guān)于iOS實現(xiàn)UIScrollView的無限輪播功能(原理)的相關(guān)資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下2018-09-09
iOS CAEmitterLayer實現(xiàn)粒子發(fā)射動畫效果
這篇文章主要為大家詳細介紹了iOS CAEmitterLayer 實現(xiàn)粒子發(fā)射動畫效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06
詳解iOS tableViewCell自適應(yīng)高度 第三發(fā)類庫
在github中有許多大牛封裝好的第三發(fā)類庫,其中有個自適應(yīng)cell高度的類庫。接下來通過本文給大家介紹iOS tableViewCell自適應(yīng)高度 第三發(fā)類庫,需要的朋友參考下2016-04-04
iOS使用pageViewController實現(xiàn)多視圖滑動切換
這篇文章主要為大家詳細介紹了iOS使用pageViewController實現(xiàn)多視圖滑動切換,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-06-06
iOS的UIColor類與其相關(guān)類之間的區(qū)別及判斷相等的方法
這篇文章主要介紹了iOS的UIColor類與其相關(guān)類之間的區(qū)別及判斷相等的方法,主要是對比了CGColor和CIColor,需要的朋友可以參考下2015-10-10

