Ios SDWebImage不工作

Ios SDWebImage不工作,ios,objective-c,sdwebimage,Ios,Objective C,Sdwebimage,我正在尝试使用SDWebImage从web下载图像。但它不起作用。我怎样才能修好它 DetailView.m: #import "DetailViewController.h" #import "UIImageView+WebCache.h" - (void)viewDidLoad { [super viewDidLoad]; [self.imageView sd_setImageWithURL: [NSURL URLWithString:_downloadedimage]

我正在尝试使用SDWebImage从web下载图像。但它不起作用。我怎样才能修好它

DetailView.m:

#import "DetailViewController.h"
#import "UIImageView+WebCache.h"

- (void)viewDidLoad {
    [super viewDidLoad];

    [self.imageView sd_setImageWithURL: [NSURL URLWithString:_downloadedimage]
                   placeholderImage:[UIImage imageNamed:@"image.png"]];

    self.imageView.frame = (CGRect){.origin=CGPointMake(1.0f, 1.0f), .size=_img.size};  // I think what error here
    [self.scrollView addSubview:self.imageView];

    self.scrollView.contentSize = _img.size; // and here?
}

谢谢您的帮助。

首先导入库

#import <SDWebImage/UIImageView+WebCache.h>

请确保您使用的是包含某些图像的有效url,并且您分配给占位符的图像也应该存在。

首先导入库

#import <SDWebImage/UIImageView+WebCache.h>

请确保您使用的是包含某些图像的有效url,并且您分配给占位符的图像也应该存在。

首先导入库

#import <SDWebImage/UIImageView+WebCache.h>

请确保您使用的是包含某些图像的有效url,并且您分配给占位符的图像也应该存在。

首先导入库

#import <SDWebImage/UIImageView+WebCache.h>

确保您使用的有效url包含一些图像,并且您分配给占位符的图像也应该存在。

看起来您没有初始化imageview。试着在之前做

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (self.imageView == nil)
        self.imageView = [[UIImageView alloc] init];
    [self.imageView sd_setImageWithURL: [NSURL URLWithString:_downloadedimage] placeholderImage:[UIImage imageNamed:@"image.png"]];
    //...
}

看起来您没有初始化imageview。试着在之前做

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (self.imageView == nil)
        self.imageView = [[UIImageView alloc] init];
    [self.imageView sd_setImageWithURL: [NSURL URLWithString:_downloadedimage] placeholderImage:[UIImage imageNamed:@"image.png"]];
    //...
}

看起来您没有初始化imageview。试着在之前做

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (self.imageView == nil)
        self.imageView = [[UIImageView alloc] init];
    [self.imageView sd_setImageWithURL: [NSURL URLWithString:_downloadedimage] placeholderImage:[UIImage imageNamed:@"image.png"]];
    //...
}

看起来您没有初始化imageview。试着在之前做

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (self.imageView == nil)
        self.imageView = [[UIImageView alloc] init];
    [self.imageView sd_setImageWithURL: [NSURL URLWithString:_downloadedimage] placeholderImage:[UIImage imageNamed:@"image.png"]];
    //...
}


不工作?详细解释你期望的是什么以及你得到了什么?这是一个关于SWWebImage的类似问题,如果你看这个答案,它可能会帮助ImageView始终为空。你是否验证了
self.ImageView
不是
nil
?我在代码
中写了if(_ImageView.image==nil){AlertView}
,我得到的图像视图总是零。不工作?详细解释你期望的是什么以及你得到了什么?这是一个关于SWWebImage的类似问题,如果你看这个答案,它可能会帮助ImageView始终为空。你是否验证了
self.ImageView
不是
nil
?我在代码
中写了if(_ImageView.image==nil){AlertView}
,我得到的图像视图总是零。不工作?详细解释你期望的是什么以及你得到了什么?这是一个关于SWWebImage的类似问题,如果你看这个答案,它可能会帮助ImageView始终为空。你是否验证了
self.ImageView
不是
nil
?我在代码
中写了if(_ImageView.image==nil){AlertView}
,我得到的图像视图总是零。不工作?详细解释你期望的是什么以及你得到了什么?这是一个关于SWWebImage的类似问题,如果你看这个答案,它可能会帮助ImageView始终为空。你是否验证了
self.ImageView
不是
nil
?我在代码
中写了if(_ImageView.image==nil){AlertView}
,我得到的ImageView总是为零。标记为右的答案是相同的,所以为什么被否决。标记为右的答案是相同的,所以为什么被否决。标记为右的答案是相同的,所以为什么被否决。标记为右的答案是相同的,所以为什么被否决。