2010-01-28 73 views

回答

7

下面的代碼可以幫助你......

在UITableView2的.h文件中:

聲明變量

UIActivityIndicatorView *progressInd; 

創造財產

@property (nonatomic, retain) UIActivityIndicatorView *progressInd; 

和申報方法

- (UIActivityIndicatorView *)progressInd; 
在UITableView2的.m文件

@synthesize progressInd; 

- (void)viewDidLoad方法定義該方法(調整X,Y,寬度,寬度的位置)

- (UIActivityIndicatorView *)progressInd { 
if (progressInd == nil) 
{ 
    CGRect frame = CGRectMake(self.view.frame.size.width/2-15, self.view.frame.size.height/2-15, 30, 30); 
    progressInd = [[UIActivityIndicatorView alloc] initWithFrame:frame]; 
    [progressInd startAnimating]; 
    progressInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 
    [progressInd sizeToFit]; 
    progressInd.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | 
            UIViewAutoresizingFlexibleRightMargin | 
            UIViewAutoresizingFlexibleTopMargin | 
            UIViewAutoresizingFlexibleBottomMargin); 

    progressInd.tag = 1; // tag this view for later so we can remove it from recycled table cells 
} 
return progressInd; 
} 

在您的解析開始

[self.view addSubview:self.progressInd]; 

使用以下行解析結束處

[self.progressInd removeFromSuperview]; 
+0

謝謝。它工作正常。 – Warrior 2010-01-28 10:36:12