ios - PFImageView url 显示解析

标签 ios objective-c imageview parse-platform sigabrt

已经 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 (或类似的通用解决方案)用于单元格上的 ImageView 。


使用 SDWebImage 您将替换:

    cell.imagevieww.file= [object objectForKey:@"ImageURL"];
    [cell.imagevieww loadInBackground];

与:

    [cell.imagevieww setImageWithURL:[NSURL URLWithString:[object objectForKey:@"ImageURL"]]
                    placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

关于ios - PFImageView url 显示解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21149468/

相关文章:

objective-c - 带有嵌套 View Controller 的 iOS 自定义导航

iphone - 如何确定我们的设备中是否存在iPhone应用程序(上一个/下一个版本)?

android - 滚动时 Gridview 内的 ImageView 重复图像(使用 ImageDownloader)

android - 设置后让ImageView消失

objective-c - 在运行时更改 iOS 4 中应用程序的图标

ios - 检测旋转的 UIView 之间的碰撞

iphone - 如何使用 Objective C 更改 iOS 设备的系统墙纸/背景?

android - ImageView 和 offset 后面的 ImageButton

ios - 限制 UIDate View 滚动到旧日期?

ios - 使用 .csv 文件创建对象 Objective-C