【发布时间】:2014-11-02 19:49:27
【问题描述】:
下午好,
我在原型单元格中显示图像时遇到问题。目前我只能显示标签文本,我想知道我必须做什么才能显示图像。
这是当前进程的截图:
我有图片的 URL,但目前只显示为标签:
http://i.stack.imgur.com/P8l5t.png
我想将其显示为图像。我必须做什么才能实现这一目标?
ViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Retrieve cell
NSString *cellIdentifier = @"BasicCell";
UITableViewCell *myCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
// Get the location to be shown
Location *item = _feedItems[indexPath.row];
// Get references to labels of cell
myCell.textLabel.text = item.address;
return myCell;
}
提前致谢。
【问题讨论】:
-
但是您甚至没有尝试在此处添加图像...您可以将图像添加为子视图或使用单元格的图像属性。
-
我在 MainStoryBoard 中添加了一个 imageView。
-
但是在你的 cellForRowAtIndexPath 中,你只是设置了你的单元格的文本标签属性...
item.address是图片的网址吗? -
是的,item.address就是图片的url路径。如何设置单元格的图像属性?谢谢林赛。
-
图片 url 在网站中,完整的 url 路径。谢谢。
标签: javascript ios xcode