2013-10-12 120 views

回答

3

嘗試這樣

UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"NoReuse"] autorelease]; 
cell.textLabel.text = @"Loading..."; 

UIActivityIndicatorView *spinner = [[[UIActivityIndicatorView alloc] 
    initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease]; 

// Spacer is a 1x1 transparent png 
UIImage *spacer = [UIImage imageNamed:@"spacer"]; 

UIGraphicsBeginImageContext(spinner.frame.size); 

[spacer drawInRect:CGRectMake(0,0,spinner.frame.size.width,spinner.frame.size.height)]; 
UIImage* resizedSpacer = UIGraphicsGetImageFromCurrentImageContext(); 

UIGraphicsEndImageContext(); 
cell.imageView.image = resizedSpacer; 
[cell.imageView addSubview:spinner]; 
[spinner startAnimating]; 

return cell; 
+1

@ sonbt91是它的工作 – Sport

+0

謝謝,它的工作! – sonbt91

1
UIActivityIndicatorView *spinner = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] autorelease]; 
spinner.frame = CGRectMake(205.0f, 0.0f, 44.0f, 44.0f); 
spinner.tag = 3; 
[cell.contentView addSubview:spinner]; 
+1

如果您提供代碼,請詳細說明,以便向OP說明。 – Abbas

相關問題