iOS UIAlertView中UIActivityindicatorView風火輪提示載入等待

來源:互聯網
上載者:User

iOS UIAlertView中UIActivityindicatorView風火輪提示載入等待

 

1、SignInViewController.h

 

#import @interface SignInViewController : UIViewController{    UIAlertView *remoteAlertView;}@end

 

2、SignInViewController.m

 

#import SignInViewController.h@interface SignIniewController ()@end@implementation SignInViewController-(void)dealloc{    if (remoteAlertView) {        [remoteAlertView release];    }    [super dealloc];}// 方法內:    // 遠程webservice方法    RemoteLogic *remoteLogic = [[RemoteLogic alloc] init];    // 啟動動畫    [self remoteAnimation:@正在擷取伺服器時間, 請稍候...];    // 非同步載入資料    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{        // 擷取webservice資料        delegate.serverTime = remoteLogic.getServerTime;        dispatch_async(dispatch_get_main_queue(), ^{            // 關閉動畫            [remoteAlertView dismissWithClickedButtonIndex:0 animated:YES];            // 擷取webservice資料後操作 do something        });    });#pragma mark - Animation-(void)remoteAnimation:(NSString *)message{    if (remoteAlertView) {        [remoteAlertView release];    }    remoteAlertView =  [[UIAlertView alloc] initWithTitle:@提示 message:message delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil ];    UIActivityIndicatorView *aiView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125.0, 80.0, 30.0, 30.0)];    aiView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;    //check if os version is 7 or above. ios7.0及以上UIAlertView棄用了addSubview方法    if ([[[UIDevice currentDevice] systemVersion] compare:@7.0] != NSOrderedAscending) {        [remoteAlertView setValue:aiView forKey:@accessoryView];    }else{        [remoteAlertView addSubview:aiView];    }    [remoteAlertView show];    [aiView startAnimating];    [aiView release];}

3、效果ios5.1,ios7.1.2

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.