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

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

问题描述

已经过了1周,我仍然停留在PFImageView上。我重新制作了一切。从UITableView更改为PFQueryTableView,然后尝试使用UITableViewCell显示图像,然后使用PFTableViewCell,并且在每种方法中,只有用于显示的内容才是标签。每当我运行我的应用程序时,我会因为这行而崩溃(SIGABRT):`

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: `

崩溃行


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


任何人都可以帮我解决这个问题吗?非常感谢

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

TableViewController.h

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

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

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 设置为字符串并让它工作。

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.

如果你正在使用网上任意图像的普通网址然后你应该使用 SDWebImage (或类似的通用解决方案)用于单元格上的图像视图。

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.

SDWebImage 你要替换:

    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天全站免登陆