Ios 将图像查询到UITableView
我正在尝试在我的Ios 将图像查询到UITableView,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我正在尝试在我的UITableview中查询图像,但在尝试配置单元格时遇到问题。创建UITableViewCell的子类,并向其添加UIImageView属性。下面是头文件的示例: #import <UIKit/UIKit.h> @interface CustomTableViewCell : UITableViewCell @property (nonatomic, weak) IBOutlet UIImageView *icon; //@property (nonatomi
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
另外,请确保在主线程上调用
reloadData
您需要在主线程上重新加载表,而不是在后台线程上。但是,我应该在UIImage*YourImageWhere图像中放入什么。如何从PFObject
s获取图像?我在问你一个问题,我不知道你在PFObject
s中存储了什么。好的,请看我的编辑。您需要了解图像的存储方式,并将其相应地放入图像视图中。这可能有助于您:
- (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;
}