为什么单元格在这段代码中没有显示任何内容:
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[cell.imageView addSubview:spinner];
[spinner startAnimating];
cell.textLabel.text=@"Carregando...";
[spinner release];
我在里面做这个tableView:cellForRowAtIndexPath:
.
我尝试了合适的尺寸,创建了一个框架cell.imageView
和旋转器的相同尺寸的框架,但没有任何作用。
这段代码有什么问题?
谢谢..!
对蒂亚戈的方法稍作修改:
我认为将微调器直接添加到单元格视图中感觉有点老套,所以我使用 1x1 透明 png 作为图像视图,并将其大小调整为我的微调器大小:
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;
这给出了一个看起来像这样的单元格:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)