你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> IOS學習筆記(八)之UIActivityIndicatorView(活動指示器視圖)的基本概念和使用方法

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

編輯:IOS開發綜合

IOS學習筆記(八)之UIActivityIndicatorView(活動指示器視圖)(博客地址:http://blog.csdn.net/developer_jiangqq)

Author:hmjiangqq

Email:[email protected]

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(@"進度結束...");
}



  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved