Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

ios - Custom cell not displaying PFImageView?

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;
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...