iphone - 如何将 UIActivityIndi​​catorView 添加到 UITableViewCell?

标签 iphone ios uitableview uiactivityindicatorview

我想将 UIActivityIndi​​cator 添加到 UITableViewCell。我该怎么办?

最佳答案

这样试试

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;

关于iphone - 如何将 UIActivityIndi​​catorView 添加到 UITableViewCell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19337230/

相关文章:

ios - 动态设置放置在 UIScrollView 中的 UITableView 的框架大小

iphone - UIScrollView 偶尔会失去弹跳和流畅的滚动

iphone - UICollectionView 奇怪的滚动问题

iphone - 核心数据持久存储协调器不存在

swift - 嵌入式 TableViewController 上未显示导航栏 - Swift

iphone - 为 iPhone 构建 libxslt

ios - Swift 4 SDWEBImage 错误

iphone - 这个原始变量的初始化是否正确?

ios - iPhone 6 Plus 和所有其他较小屏幕之间的不同 UITableViewCell/UICollectionViewCell 指标

iphone - UIDocumentInteractionController Controller 问题