Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.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
Objective c MKNetworkKit-显示缓存的图像_Objective C_Ios_Mknetworkkit - Fatal编程技术网

Objective c MKNetworkKit-显示缓存的图像

Objective c MKNetworkKit-显示缓存的图像,objective-c,ios,mknetworkkit,Objective C,Ios,Mknetworkkit,底部更新 为此,我从MKNetworkKit Flickr演示中分支出来。我在一个Web服务器上有几个要显示在表中的图像。我有一个UITableViewCell子类ImageCell 以下是检索远程图像的自定义方法: -(void)setImageForCell:(NSString *)remoteFileName { self.loadingImageURLString = [NSString stringWithFormat:@"http://myserver.com/%@

底部更新

为此,我从MKNetworkKit Flickr演示中分支出来。我在一个Web服务器上有几个要显示在表中的图像。我有一个UITableViewCell子类ImageCell

以下是检索远程图像的自定义方法:

-(void)setImageForCell:(NSString *)remoteFileName {

    self.loadingImageURLString =
    [NSString stringWithFormat:@"http://myserver.com/%@.png",remoteFileName];
    self.imageLoadingOperation = [ApplicationDelegate.imageDownloader imageAtURL:[NSURL URLWithString:self.loadingImageURLString]
                            onCompletion:^(UIImage *fetchedImage, NSURL *url, BOOL isInCache) {

                                if([self.loadingImageURLString isEqualToString:[url absoluteString]]) {

                                    if (isInCache) {
                                        self.imageView.image = fetchedImage;
                                        [self.contentView drawRect:self.contentView.frame];
                                        NSLog(@"Image is in cache");
                                    } else {
                                        self.imageView.image = fetchedImage;
                                        [self.contentView drawRect:self.contentView.frame];
                                        NSLog(@"Image is not in cache");
                                    }
                                }
                            }];   
}
    //TableView.h
    //it is called like this
   //in cellForRowAtIndexPath...
   ImageCell *cell = (ImageCell *)[tableView dequeue...etc];
 MyObject *obj = [dataSource objectAtIndex:indexPath.row];
 cell.textLabel.text = obj.name;
 [cell setImageForCell:obj.name];
 return cell;
我已经检查了默认缓存目录的内容,现在里面有一些项目。现在不断滚动表格会打印“图像在缓存中”。问题是,单元格的imageView从不更新。Mugunth有一个类方法AutomaticallyNotifieServerssforkey:但我从未看到它在任何地方实现。我猜还需要另外一个步骤来告诉tableView实例使用新内容更新该行

谢谢你的意见

更新

我通过使用带有单元格和UIImageView IBOutlet的自定义接口生成器xib文件实现了这一点。不确定为什么它不能与self.imageView.image一起工作,并且想知道确切的原因。我仍然认为这是一个悬而未决的问题,因为我只想使用标准的UITababVIEW Cyter类。

< p>为什么从代码中调用“DrutReT”。那是亵渎神明! 检查imageView并检查IB连接是否良好。

为什么从代码中调用“drawRect”。那是亵渎神明!
检查imageView并检查IB连接是否良好。

I调用PrepareForuse。是否将self.imageView.image设置为nil?
如果是,不要这样做,因为它看起来从未重新初始化过。

I调用prepareforuse。是否将self.imageView.image设置为nil?
如果是,请不要这样做,因为它看起来从未重新初始化过。

imageView属性没有IBOutlet,因为我使用的是非接口生成器类。(未分类的UITableViewCell)。我添加了drawRect:in,在它第一次不起作用之后,我认为我必须更新contentView的那部分。如果是这样,请检查将图像添加到contentView的代码。我猜imageView会在方法作用域结束后解除分配。imageView属性没有IBOutlet,因为我使用的是非接口生成器类。(未分类的UITableViewCell)。我添加了drawRect:in,在它第一次不起作用之后,我认为我必须更新contentView的那部分。如果是这样,请检查将图像添加到contentView的代码。我猜imageView在方法作用域结束后会被释放。