Objective-C UITableView细胞图像 [英] Objective-C UITableView cell image
问题描述
所以我有一个Facebook好友的 UITableView ,对于我想要添加图像的单元格。
So I have a UITableView of Facebook Friends and for a cell I want to add the image to it.
当我尝试以下代码:
cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString: (@"http://graph.facebook.com/shaverm/picture")]]];
一切正常。虽然这是对图像目的地的硬编码,但是当我做这样的事情时:
Everything works fine. Although that's hardcoding the image destination but when I do something like this:
cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString: (@"http://graph.facebook.com/%@/picture", thisFriend.friendID)]]];
它在链接之前指向@符号时向我发出警告,说明表达结果未使用。
It gives me a warning stating 'Expression result unused' whilst pointing at the @ symbol before the link.
为什么会发生这种情况的任何想法?
Any ideas why this is happening?
我也尝试过:
cell.imageView.image = [UIImage imageNamed:thisFriend.friendPhoto];
但是这给了我一个'不兼容的指针类型,将UIImage发送到NSString类型的参数'警告。
But that's giving me a 'Incompatible pointer types sending UIImage to parameter of type NSString' warning.
推荐答案
替换:(@http://graph.facebook.com/%@/picture, thisFriend.friendID)
with this:
replace: (@"http://graph.facebook.com/%@/picture", thisFriend.friendID)
with this:
[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture", thisFriend.friendID];
看起来你忘记了格式化字符串的方法。
Looks like you just forgot the method for formatting a string.
这篇关于Objective-C UITableView细胞图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!