【问题标题】:PFImageView url displaying parsePFImageView url 显示解析
【发布时间】:2014-01-15 22:18:48
【问题描述】:

已经 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

【问题讨论】:

  • 您设置的ImageURL 是什么?崩溃是哪条线?异常消息和堆栈跟踪是什么?
  • 我的 parse.com 上有名为 ImageURL 的 String 类,我想通过 url 显示图像。我正在制作一些玩具列表,并有 3 个标签标题、描述和价格,在单元格的左侧我想显示图像,我将在 parse.com 上输入哪个 url 地址,刷新后它将显示与标签相同。我不想保存图像。我可以给你发故事板的照片,如果你想检查,我是什么意思。崩溃线向上更新。无论如何,如果我不t connect via ctrl imagevieww property with PFImageView in storyboards, it doesnt 崩溃。但什么也没显示。

标签: ios objective-c imageview parse-platform sigabrt


【解决方案1】:

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"]];

【讨论】:

  • 有什么作用? PFImageView 适用于 PFFile 实例,SDWebImage 适用于任意 URL。不清楚你在问什么。
  • 我的意思是我在使用 Parse.com 时遇到了麻烦。我的应用程序是用 Parse.com 制作的,我只想显示来自 Parse.coms data browser. So I am not sure how to customize SBWebImage with parse. Thats 的 url 字符串的图像我需要知道的。希望你现在能理解我
  • 您无需自定义SDWebImage,您只需为其提供一个根据您当前拥有的字符串创建的 URL。
  • 谢谢!!终于明白了。 2周后,它终于起作用了。非常感谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多