PFImageView的URL显示parsing
这已经1个星期了,我仍然坚持在PFImageView。 我重拍了一切。 从UITableView更改为PFQueryTableView,然后尝试用UITableViewCell显示图像,然后用PFTableViewCell显示图像,并且在每种方法中只显示标签。 每当我运行我的应用程序,我碰到(SIGABRT),因为这一行:`
崩溃线
cell.imagevieww.file= [object objectForKey:@"ImageURL"]; [cell.imagevieww loadInBackground];
任何人都可以帮我解决这个问题吗? 非常感谢
TableViewController.h
#import <Parse/Parse.h> #import "Customcell.h" #import "DetailViewController.h" @interface TableeViewController : PFQueryTableViewController { NSArray *colorsArray; } @property (strong, nonatomic) IBOutlet UITableView *colorsTable; @end
TableViewController.m
#import "TableeViewController.h" #import "TableViewCell.h" #import "DetailViewController.h" @interface TableeViewController () @end @implementation TableeViewController @synthesize colorsTable; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (id)initWithCoder:(NSCoder *)aCoder { self = [super initWithCoder:aCoder]; if (self) { // The className to query on self.parseClassName = @"Hracky1"; // Whether the built-in pull-to-refresh is enabled self.pullToRefreshEnabled = YES; // Whether the built-in pagination is enabled self.paginationEnabled = NO; } return self; } - (void)viewDidLoad { [super viewDidLoad]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object { static NSString *CellIdentifier = @"colorsCell"; CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if (cell == nil) { cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } cell.imagevieww.file= [object objectForKey:@"ImageURL"]; [cell.imagevieww loadInBackground]; cell.cellTitle.text = [object objectForKey:@"cellTitle"]; cell.cellDescript.text = [object objectForKey:@"cellDescript"]; return cell; } @end
Customcell.h
#import <Parse/Parse.h> @interface TableViewCell : PFTableViewCell @property (strong, nonatomic) IBOutlet UILabel *cellTitle; @property (strong, nonatomic) IBOutlet UILabel *cellDescript; @property (strong, nonatomic) IBOutlet UILabel *price; @property (strong, nonatomic) IBOutlet PFImageView *imagevieww; @end
PFImageView
仅链接到Parse.com上存储的文件,由PFFile
对象表示。 您不能将cell.imagevieww.file
设置为一个string,并使其工作。
如果您在networking上使用正常的URL来访问任意图像,那么您应该使用SDWebImage
(或类似的通用解决scheme)来查看单元格上的图像视图。
使用SDWebImage
您可以replace:
cell.imagevieww.file= [object objectForKey:@"ImageURL"]; [cell.imagevieww loadInBackground];
有:
[cell.imagevieww setImageWithURL:[NSURL URLWithString:[object objectForKey:@"ImageURL"]] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];