iOS progressview的簡單使用

來源:互聯網
上載者:User

標籤:c   class   blog   java   a   http   

head 代碼。。 

Java代碼  
  1. #import <UIKit/UIKit.h>  
  2.   
  3. @interface ViewController : UIViewController  
  4. {  
  5.     UIProgressView *progressview;  
  6.     UIProgressView *progressviewbar;  
  7.     NSTimer *timer;  
  8. }  
  9. @property(retain,nonatomic)  
  10. IBOutlet UIProgressView *progressview;  
  11. @property(retain,nonatomic)  
  12. IBOutlet UIProgressView *progressviewbar;  
  13.   
  14. -(IBAction)startprogress:(id)sender;  
  15. -(IBAction)stopprogress:(id)sender;  
  16.   
  17. @end  


m 代碼 

Java代碼  
    1. #import "ViewController.h"  
    2.   
    3. @interface ViewController ()  
    4.   
    5. @end  
    6.   
    7. @implementation ViewController  
    8. @synthesize progressview;  
    9. @synthesize progressviewbar;  
    10. - (void)viewDidLoad  
    11. {  
    12.     [super viewDidLoad];  
    13.       
    14.     // Do any additional setup after loading the view, typically from a nib.  
    15. }  
    16.   
    17. - (void)didReceiveMemoryWarning  
    18. {  
    19.     [super didReceiveMemoryWarning];  
    20.     // Dispose of any resources that can be recreated.  
    21. }  
    22. /* 啟動進度條 */  
    23. -(IBAction)startprogress:(id)sender{  
    24.     timer = [NSTimer scheduledTimerWithTimeInterval:0.03f target:self selector:@selector(timeChanged:) userInfo:nil repeats:YES];  
    25.       
    26.     /* 
    27.      啟動一個定時器,間隔時間為0.03s,間隔0.03s即調用self裡邊的timechanged方法 
    28.      */  
    29.   
    30. }  
    31. /* 停止進度條,進度都置為零*/  
    32. -(IBAction)stopprogress:(id)sender{  
    33.     [timer invalidate];  
    34. //    [timer release];  
    35.     timer = nil;  
    36.     self.progressview.progress=0.0f;  
    37.     self.progressviewbar.progress=0.0f;  
    38. }  
    39. /* 進度條進度+0.01*/  
    40. -(IBAction)timeChanged:(id)sender{  
    41.   
    42.     self.progressview.progress +=0.01f;  
    43.     self.progressviewbar.progress+=0.01f;  
    44. }  
    45. @end  

聯繫我們

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