因此,我有一个Facebook Friends的 UITableView ,对于一个单元格,我想向其中添加图像。
当我尝试以下代码时:
cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString: (@"http://graph.facebook.com/shaverm/picture")]]];
一切正常。虽然这是对图像目标进行硬编码,但是当我做这样的事情时:
cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString: (@"http://graph.facebook.com/%@/picture", thisFriend.friendID)]]];
它给我一个警告,指出“未使用表达式结果”,同时指向链接前的@符号。
任何想法为什么会这样?
我也尝试过:
cell.imageView.image = [UIImage imageNamed:thisFriend.friendPhoto];
但这给了我一个“不兼容的指针类型,将UIImage发送到NSString类型的参数”警告。
最佳答案
用以下内容替换:(@"http://graph.facebook.com/%@/picture", thisFriend.friendID)
:
[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture", thisFriend.friendID];
看起来您只是忘记了格式化字符串的方法。
关于ios - Objective-C UITableView单元格图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18594884/