在iOS中使用SDWebImage从磁盘加载映像时连接中断错误

时间:2015-09-08 18:21:28

标签: ios iphone cocoa-touch sdwebimage

从磁盘加载多个图像时出现此错误。我使用SDWebImage加载图片,但仍然收到此错误,然后应用程序崩溃。我不知道这个错误是什么。请给我adivse。非常感谢。

 Communications error: <OS_xpc_error: <error: 0x322eb614> { count = 1, contents =
    "XPCErrorDescription" => <string: 0x322eb86c> { length = 22, contents = "Connection interrupted" }
}>

以下是我用来为scrollview

创建列表缩略图的代码
 -(void) createPropertyThumbnails:(NSArray*) array
    {
        int xCoord=10;
        int yCoord=7;
        int buffer = 7;

        for (int pos = 0; pos < array.count; pos++) {
// CREATE VIEW CONTAINS UIIMAGEVIEW HERE
            ThumbnailView* thumbnaiCell = [[humbnailView alloc] initWithFrame:CGRectMake(xCoord, yCoord,THUMBNAIL_WIDTH , THUMBNAIL_HEIGHT) andURLImage:array[pos]];
            thumbnaiCell.delegate = self;
            //set selected for 1st item
            if(pos ==0)
            {
                _selectedCell =thumbnaiCell;
                [_selectedCell setSelectedCell:YES];
            }

            xCoord = xCoord + THUMBNAIL_WIDTH  + buffer;

            [self.thumbnailScrollView addSubview:thumbnaiCell];
        }

        [self.thumbnailScrollView setContentSize:CGSizeMake(xCoord, self.thumbnailScrollView.frame.size.height)];

    }


    - (id)initWithFrame:(CGRect)frame andURLImage:(NSString*) url
    {
        self = [super initWithFrame:frame];
        if (self) {

            [self setupProjectThumbnail:frame andURLImage:url];

        }
        return self;
    }

    -(void) setupProjectThumbnail:(CGRect) frame andURLImage:(NSString*) url
    {
        //create load image from cache
        NSString *filePath = [[NSBundle mainBundle] pathForResource:url ofType:nil];
        NSURL *ImageURL = [NSURL fileURLWithPath:filePath];
        if (ImageURL) {
            SDWebImageManager *manager = [SDWebImageManager sharedManager];
            [manager downloadImageWithURL:ImageURL
                                  options:0
                                 progress:^(NSInteger receivedSize, NSInteger expectedSize) {
                                     // progression tracking code
                                 }
                                completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
                                    if (image) {
                                        // do something with image

                                        // imageview
                                        UIImageView* imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, frame.size.width, frame.size.height)];
                                        imageview.contentMode = UIViewContentModeScaleToFill;
                                        [self addSubview:imageview];
                                    }
                                }];
        }

    }

0 个答案:

没有答案