【发布时间】:2014-09-25 04:51:41
【问题描述】:
我正在尝试查询 UITableview 中的图像,但在尝试配置单元格时遇到问题。
【问题讨论】:
-
你需要在主线程上重新加载表格,而不是后台线程。
标签: ios objective-c uitableview
我正在尝试查询 UITableview 中的图像,但在尝试配置单元格时遇到问题。
【问题讨论】:
标签: ios objective-c uitableview
创建UITableViewCell 的子类并向其添加UIImageView 属性。以下是您的头文件的示例:
#import <UIKit/UIKit.h>
@interface CustomTableViewCell : UITableViewCell
@property (nonatomic, weak) IBOutlet UIImageView *icon;
//@property (nonatomic, strong) UIImageView *icon; //Only if you're not using an XIB/storyboard
@end
然后,您的 cellForRowAtIndexPath: 函数将类似于以下内容:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier=@"cellimage";
CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
//the following assumes that your self.images array contains UIImages
cell.icon.image = [self.images objectAtIndex:indexPath.row];
return cell;
}
另外,请务必在主线程上调用reloadData。
【讨论】:
PFObjects 中获取图片?
PFObjects 中存储了什么。