已经 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
定制单元.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
到一个字符串并让它工作。
如果您使用普通 URL 来访问网络上的任意图像,那么您应该使用SDWebImage https://github.com/rs/SDWebImage(或类似的通用解决方案)用于手机上的图像视图。
With SDWebImage
你会替换:
cell.imagevieww.file= [object objectForKey:@"ImageURL"];
[cell.imagevieww loadInBackground];
with:
[cell.imagevieww setImageWithURL:[NSURL URLWithString:[object objectForKey:@"ImageURL"]]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)