IPhone SDK:将UIActivityIndi​​catorView添加到UITableViewCell [英] IPhone SDK: Adding a UIActivityIndicatorView to a UITableViewCell

查看:155
本文介绍了IPhone SDK:将UIActivityIndi​​catorView添加到UITableViewCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么这个代码中不显示任何内容:

Why doesn't the cell show anything in this code:

UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[cell.imageView addSubview:spinner];
[spinner startAnimating];
cell.textLabel.text=@"Carregando...";
[spinner release];

我在内执行此操作tableView:cellForRowAtIndexPath:

我尝试大小适合,创建一个框架 cell.imageView 微调器,但没有什么工作。

I tried size to fit, create a frame to cell.imageView and a same size frame to the spinner, but nothing works.

此代码有什么问题?

谢谢..!

推荐答案

..

David Maymudes是偏偏正确的...有必要有一个背景cell.imageView ...但必须是一个图像,不是只是一个框架。所以只需创建一个UIImage作为白色背景,并在cell.imageView.image中设置。代码将是:

David Maymudes was partialy right... It´s necessary to have a "background" to the cell.imageView... But must be a image, not just a frame. So just create a UIImage as a "white background" and set in cell.imageView.image. The code will be:

 UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] 
        initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
 UIImage *whiteback = [[UIImage alloc] initWithContentsOfFile:@"whiteback.png"];
 cell.imageView.image = whiteback;
 [cell.imageView addSubview:spinner];
 [spinner startAnimating];
 cell.textLabel.text=@"Carregando...";
 [whiteback release];
 [spinner release];

whiteback.png只是一个25x25像素的白色方形...

The whiteback.png is just a 25x25 pixels white square...

感谢大家的帮助...见... ...

Thanks for everyone help... See you...

这篇关于IPhone SDK:将UIActivityIndi​​catorView添加到UITableViewCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆