PFImageView url 显示解析 [英] PFImageView url displaying parse

查看:17
本文介绍了PFImageView url 显示解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经 1 周了,我仍然停留在 PFImageView 上.我重做了一切.从 UITableView 更改为 PFQueryTableView,然后尝试使用 UITableViewCell 显示图像,然后使用 PFTableViewCell 并且在每种方法中只有可以显示的东西是标签.每次当我运行我的应用程序时,我都会因为这一行而崩溃(SIGABRT):`

撞线

<块引用>

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

谁能帮我解决这个问题?非常感谢

TableViewController.h

<块引用>

#import #import "Customcell.h"#import "DetailViewController.h"@interface TableeViewController :PFQueryTableViewController {NSArray *colorsArray;}@property (strong, nonatomic) IBOutlet UITableView *colorsTable;@结尾

TableViewController.m

 #import "TableeViewController.h"#import "TableViewCell.h"#import "DetailViewController.h"@interface TableeViewController()@结尾@implementation TableeViewController@合成颜色表;- (id)initWithNibName:(NSString *)nibNameOrNil 包:(NSBundle *)nibBundleOrNil{self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];如果(自我){//自定义初始化}回归自我;}- (id)initWithCoder:(NSCoder *)aCoder{self = [super initWithCoder:aCoder];如果(自我){//要查询的类名self.parseClassName = @"Hracky1";//是否开启内置的pull-to-refreshself.pullToRefreshEnabled = YES;//是否启用内置分页self.paginationEnabled = NO;}回归自我;}- (void)viewDidLoad{[超级viewDidLoad];}- (void)didReceiveMemoryWarning{[超级didReceiveMemoryWarning];//处理任何可以重新创建的资源.}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject*)目的 {静态 NSString *CellIdentifier = @"colorsCell";CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];如果(单元格 == 零){单元格 = [[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"];返回单元格;}@结尾

Customcell.h

<块引用>

#import @interface TableViewCell : PFTableViewCell@property (strong, nonatomic) IBOutlet UILabel *cellTitle;@property (strong, nonatomic) IBOutlet UILabel *cellDescript;@property (strong, nonatomic) IBOutlet UILabel *price;@property(强,非原子)IBOutlet PFImageView *imagevieww;@结尾

解决方案

PFImageView 仅链接到存储在 Parse.com 上并由 PFFile 对象表示的文件.您不能将 cell.imagevieww.file 设置为字符串并使其工作.

如果您使用普通 URL 访问网络上的任意图像,那么您应该使用 SDWebImage(或类似的通用解决方案)用于单元格上的图像视图.

<小时>

SDWebImage 替换:

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

与:

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

It has been 1 week and I am still stuck on PFImageView. I remade everything. Changed from UITableView to PFQueryTableView, then tried to display image with UITableViewCell, then with PFTableViewCell and in every method only things that works to display are labels. Everytime when I run my app I get crash(SIGABRT) because of this line: `

Crashing line

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

Can anyone help me to solve this problem? Thanks a lot

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 links only to files stored on Parse.com and represented by PFFile objects. You can't set cell.imagevieww.file to a string and have it work.

If you are using normal URLs to arbitrary images on the web then you should use SDWebImage (or a similar generic solution) for the image view on your cell.


With SDWebImage you would replace:

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

with:

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

这篇关于PFImageView url 显示解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆