Custom cell not displaying PFImageView?

风格不统一 提交于 2020-01-17 01:05:35

问题


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.

My cell's class is set as foodCell and foodcell.h is set as the owner.

Here is a screenshot showing the imageview on my NIB

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

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;
}

回答1:


As per Parse documentation, you should call loadInBackground for that PFImageView

cell.foodPic.file = [object objectForKey:@"foodImage"];
[cell.foodPic loadInBackground];



回答2:


Also call [PFImageView class] in your AppDelegate.m didFinishLaunchWithOptions: method.

source: https://parse.com/questions/using-pfimageview-with-storyboard



来源:https://stackoverflow.com/questions/20963486/custom-cell-not-displaying-pfimageview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!