我已将 UIActivityIndicator 的 IBOutlet 添加到自定义单元格,但它并未显示在每个单元格上,仅在前 2-3 上显示,然后什么也没有。另一件事,当我滚动表格并返回前 3 个单元格时,UIActivityIndicator 也会从这些单元格中消失......
代码:
细胞.h
@interface Cell : UITableViewCell
@property (strong, nonatomic) IBOutlet UIImageView *image;
@property (strong, nonatomic) IBOutlet UILabel *label;
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
@end
细胞.m
@implementation Cell
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
// change to our custom selected background view
}
return self;
}
@end
在情节提要中 UIactivityIndicator 设置为:行为: - 动画
出于测试目的...
和:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCell";
Cell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// load the image for this cell
Wallpaper *wallpaper = [xmlParser.wallpapers objectAtIndex:indexPath.row];
cell.label.text = wallpaper.title;
NSString *imageToLoad = wallpaper.thumbnail;
[cell.image setImageWithURL:[NSURL URLWithString:imageToLoad] placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSUInteger receivedSize, long long expectedSize)
{
}
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType)
{
//[cell.activityIndicator stopAnimating];
}];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(tapped:)];
[cell.image addGestureRecognizer:tap];
[cell.image setTag:indexPath.row];
CALayer * l = [cell.image layer];
[l setMasksToBounds:YES];
[l setCornerRadius:5.0];
cell.layer.cornerRadius = 7.0;
return cell;
}