2

听起来有点奇怪,但由于我使用了旋转轮指示器,因此延迟图像加载不适用于第一个图像视图(这些曾经显示在第一个屏幕中)。如果用户向下滚动 TableView 中的所有其他图像,则通过延迟下载正确加载。

主要问题是,那NSURLConnection没有调用didReceiveData.

- (void)startDownload
{
    self.activeDownload = [NSMutableData data];

    BOOL firstCell = (self.indexPathInTableView.row==0 && self.indexPathInTableView.section==0);
    if(firstCell){
        NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:
                                 [NSURLRequest requestWithURL:
                                  [NSURL URLWithString:newsContent.title_picture]] delegate:self];
        NSLog(@"Get Title Pic %@ (%@)",newsContent.title, newsContent.title_picture);
        self.imageConnection = conn;
    }else{
        NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:
                                 [NSURLRequest requestWithURL:
                                  [NSURL URLWithString:newsContent.cover_picture]] delegate:self];

        NSLog(@"Get Thumb Pic %@ (%@)",newsContent.title, newsContent.cover_picture);
        self.imageConnection = conn;
    }
}


- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    NSLog(@"[NewsPicture][connection]didReceiveData");
    [self.activeDownload appendData:data];
}

编辑:添加didReceiveResponse

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    NSLog(@"[NewsPicture][connection]didReceiveResponse");
}

我将获得带有正确 URL 的日志“ Get Thumb Pic ... (...) ”,但对于前 5 行(它们填满 iPhone 4 的屏幕),我没有收到“日志” [NewsPicture][connection]didReceiveData "。

这就是我调用指标的方式:

// Spinning Wheel
HUD = [[MBProgressHUD alloc] initWithView:self.view];
HUD.tag = 1000;
[self.view addSubview:HUD];
HUD.delegate = self;

HUD.labelText = @"wird geladen";
HUD.minShowTime = 25;
HUD.dimBackground = YES;
[HUD show:true];

[HUD showWhileExecuting:@selector(doWhileLoadingNews) onTarget:self withObject:nil animated:NO];

如果我只打电话

[self doWhileLoadingNews];

在这个地方一切正常,但没有加载数据的指示器。

我该如何解决?(如果您需要,我可以发布更多代码或信息)

编辑:我仍然无法修复它。是否有可能以另一种方式捕获结果,然后调用“didReceiveData”?

编辑:添加didReceiveResponse但结果相同,didReceiveResponse也没有调用。

4

0 回答 0