IOS學習筆記(八)之UIActivityIndicatorView(活動指標視圖)的基本概念和使用方法

來源:互聯網
上載者:User

IOS學習筆記(八)之UIActivityIndicatorView(活動指標視圖)(部落格地址:http://blog.csdn.net/developer_jiangqq)

Author:hmjiangqq

Email:jiangqqlmj@163.com

UIActivityIndicatorView:

作用:進行提示使用者當前正在載入進度,該控制項可以消除使用者等待的心理事件,增加使用者體驗。

首先來看下官方解說:


Use an activity indicator to show that a task is in progress. An activity indicator appears as a “gear” that is either spinning or stopped.

You control when an activity indicator animates by calling the startAnimating and stopAnimating methods. To automatically hide the activity indicator when animation stops, set the hidesWhenStopped property to YES.

常用的屬性和方法:


- (void)startAnimating; //開始進度動畫

- (void)stopAnimating; //停止進度動畫

- (BOOL)isAnimating; //檢測是否動畫在執行

執行個體代碼:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];    // Override point for customization after application launch.    self.window.backgroundColor = [UIColor redColor];        UIActivityIndicatorView *activityView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];    activityView.center=CGPointMake(160, 155);    [activityView startAnimating];    [self.window addSubview:activityView];    [activityView release];        //定時3s之後,自動停止運行    [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(test:) userInfo:activityView repeats:NO];        [self.window makeKeyAndVisible];    return YES;}-(void)test:(NSTimer *)timer{    UIActivityIndicatorView *view=timer.userInfo;    [view stopAnimating];    NSLog(@"進度結束...");}



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.