Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone SDWebImage不显示下载图像_Iphone_Uiscrollview_Uiimageview_Uibutton_Sdwebimage - Fatal编程技术网

Iphone SDWebImage不显示下载图像

Iphone SDWebImage不显示下载图像,iphone,uiscrollview,uiimageview,uibutton,sdwebimage,Iphone,Uiscrollview,Uiimageview,Uibutton,Sdwebimage,我使用SDWebImage库从服务器下载远程图像。但是,当im处于边缘连接时,需要花费太多时间,下载NSLog后,会在ui按钮下显示值,但不会显示图像 代码: int-Width=0; 对于(int i=0;i这里有些东西对我有效,我保留循环,但我不使用它,因此它与您的代码匹配。我声明imgView1是UIButton,并硬编码了一个指向stackoverflow图像的URL。我建议您检查imgView1的类型和productimg_数组的内容 int Width = 0; UIButton *

我使用
SDWebImage
库从服务器下载远程图像。但是,当im处于边缘连接时,需要花费太多时间,下载
NSLog
后,会在
ui按钮下显示值,但不会显示图像

代码:

int-Width=0;

对于(int i=0;i这里有些东西对我有效,我保留循环,但我不使用它,因此它与您的代码匹配。我声明imgView1是UIButton,并硬编码了一个指向stackoverflow图像的URL。我建议您检查imgView1的类型和productimg_数组的内容

int Width = 0;
UIButton *imgView1;
for (int i = 0; i<1; i++ ) {


    imgView1=[[UIButton alloc]initWithFrame:CGRectMake(20+(i*74), 0, 72, 72)];

    Width = Width + 20+(i*74);

    [imgView1 setTag:i+1];

    [imgView1 addTarget:self action:@selector(cancelPressed:) forControlEvents:UIControlEventTouchUpInside];

    [imgView1 setImageWithURL:[NSURL URLWithString:@"http://cdn.sstatic.net/stackoverflow/img/sprites.png?v=6"]  forState:UIControlStateNormal completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {

        NSLog(@"download images 1");
    }];

    [self.view addSubview:imgView1];

}
int-Width=0;
UIButton*imgView1;

对于(int i=0;i您可以从
ui按钮+WebCache.h

- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state;
称之为类似

[imgView1 setImageWithURL:[NSURL URLWithString:[productimg_array objectAtIndex:i]] forState:UIControlStateNormal];
此方法将下载图像并直接将其设置为按钮


希望有帮助!

可能有错误或超时。请尝试此更改,也许我们可以找到更多信息:

[imgView1 setImageWithURL:[NSURL URLWithString:[productimg_array objectAtIndex:i]]  forState:UIControlStateNormal completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
    if(error){
        NSLog(@"Callback Error:%@",error);
    }
    if(image){
        NSLog(@"Callback Image:%@",image);
    }
}];

您在何处声明imgView1?如何保留它?因为变量名暗示它是一个imageView,但您正在为它分配一个UIButton。我使用了上面的代码。但是,当我处于边缘连接时,加载它花费了太多时间,而im处于wifi时,加载它fast@user2807197这是无法控制的。下载性能wiI’我将始终依赖于网络速度。很抱歉,在代码中您无法提高网络速度。您不理解我的要求。我在.h文件中声明imgView1并启用ARC。productimg_阵列具有来自远程映像的所有映像。当我使用EDGE时,我遇到错误:回调错误:错误域=NSURLErrorDomain Code=-1001“操作无法完成。(NSURErrorDomain错误-1001。)”UserInfo=0x20bde570{NSErrorFailingURLKey=}URL是否有http://infront,或者只是堆栈溢出格式不正确?这是示例URL。我没有使用服务器URL。如果您确实有错误,那么您可能希望增加通过SDWebImage下载的图像的超时时间,这些图像有多大,从何处下载?在何处?如何?加载imag自动使用纵横比从服务器删除
[imgView1 setImageWithURL:[NSURL URLWithString:[productimg_array objectAtIndex:i]]  forState:UIControlStateNormal completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
    if(error){
        NSLog(@"Callback Error:%@",error);
    }
    if(image){
        NSLog(@"Callback Image:%@",image);
    }
}];