自定义单元格不显示 PFImageView? [英] Custom cell not displaying PFImageView?
问题描述
我有一个使用 NIB 的自定义 PFTableViewCell
.我所有的自定义标签都会显示,但我的 PFImageView
没有.我将所有内容更改为 UIImageView
只是为了确保我的 Parse 调用没有问题,但即使在我的资源中设置静态图像,我也无法让它工作.
I have a custom PFTableViewCell
using a NIB. All of my custom labels display, but my PFImageView
does not. I changed everything to a UIImageView
just to make sure it wasn't something wrong with my Parse call, but I couldn't get it to work even with setting a static image in my resources.
我的单元格的类设置为 foodCell
并且 foodcell.h 设置为所有者.
My cell's class is set as foodCell
and foodcell.h is set as the owner.
这是我的 NIB
这是我的 foodCell.h,用于显示 PFImageView
的出口:
Here is my foodCell.h to show the outlet of the 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
:
Now here is where I configure my cell. Again, all of my other code here works, except the 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:@"%1@", [object objectForKey:@"foodPrice"]]];
cell.priceLabel.text = myString;
return cell;
}
推荐答案
根据 Parse 文档,你应该为那个 PFImageView
As per Parse documentation, you should call loadInBackground
for that PFImageView
cell.foodPic.file = [object objectForKey:@"foodImage"];
[cell.foodPic loadInBackground];
这篇关于自定义单元格不显示 PFImageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!