自定义单元格不显示PFImageView?
问题描述:
我有一个使用NIB的自定义PFTableViewCell
。我所有的自定义标签都会显示,但我的PFImageView
没有。我将所有内容都更改为UIImageView
,以确保它在我的Parse调用中没有出现问题,但即使在我的资源中设置了静态图像,我也无法使其工作。自定义单元格不显示PFImageView?
我的小区班级设置为foodCell
,foodcell.h设置为所有者。
下面是该ImageView的截图上我NIB
这是我foodCell.h展现PFImageView
的出口:
#import <Parse/Parse.h>
@interface foodCell : PFTableViewCell
@property (weak, nonatomic) IBOutlet NSObject *foodCell;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *foodDescription;
@property (weak, nonatomic) IBOutlet UILabel *foodTitle;
@property (strong, nonatomic) IBOutlet PFImageView *foodPic;
@end
现在,这里是我配置我的细胞。同样,我所有的其他代码在这里工作,除了foodCell.foodPic.file
:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
static NSString *CellIdentifier = @"foodCell";
foodCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[foodCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.foodPic.file = [object objectForKey:@"foodImage"];
cell.foodTitle.text = [object objectForKey:@"foodName"];
cell.foodDescription.text = [object objectForKey:@"foodDescription"];
NSString *myString = [@"$" stringByAppendingString:[NSString stringWithFormat:@"%[email protected]", [object objectForKey:@"foodPrice"]]];
cell.priceLabel.text = myString;
return cell;
}
答
按照解析文档,你应该叫loadInBackground
为PFImageView
cell.foodPic.file = [object objectForKey:@"foodImage"];
[cell.foodPic loadInBackground];
答
也叫[PFImageView class]
在AppDelegate.m didFinishLaunchWithOptions:
方法。
来源:https://parse.com/questions/using-pfimageview-with-storyboard