2

It sounds a bit strange, but since i use a spinning wheel indicator, the lazy image load don't works for the first image views (these once that are shown in the first screen). If the user scrolls down all other Images in the TableView loading correctly by a lazy download.

The main problem is, that NSURLConnection didn't calls 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];
}

Edit: Added didReceiveResponse

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

I'll get the Log "Get Thumb Pic ... (...)" with a correct Url, but for the for the first 5 rows (they fills the screen of an iPhone 4) i don't get the Log "[NewsPicture][connection]didReceiveData".

This is the way how i call the Indicator:

// 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];

and if i only call

[self doWhileLoadingNews];

at this place all works fine, but without in indicator for loading data.

How could i fix it? (I can post more Code oder Informations if you need)

Edit: I still couldn't fix it. Is it possible to catch the result in another way then calling the 'didReceiveData'?

Edit: Added didReceiveResponse but with the same result, didReceiveResponse is also not called.

  • What is the problem , the download urls are not starting downloading or they are working and images keep getting downloaded successfully and you just want to show the `HUD` while they are getting downloaded in the background? – Zen Jun 28 '13 at 17:17
  • @Zen The download is not starting, so that `didReceiveData` won't be called. I only use the Spinning Wheel Indicator while the TableViewData will be loaded (excluding the images). They will be loaded in the first time when a row is printed to the screen, but this lazy download don't start for the first images which are shown on the "start screen" (without scrolling) – Dennis Peters Jun 29 '13 at 07:46
  • Is the `conn` is returning `nil` because there might be a case if the connection instance is not initialized properly. – Zen Jun 29 '13 at 13:34
  • @Zen The NSLog shows this result __ (f.e.), it looks fine i think, but `- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data` which handles the result wouldn't be called. – Dennis Peters Jun 29 '13 at 13:48
  • I still got this problem :( ... does nobody got an idea or crude theory what it could be ? – Dennis Peters Jul 04 '13 at 07:30
  • What does `connection:didReceiveResponse:` method shows? Any kind of info like what is the response status or anything similar? – Zen Jul 04 '13 at 16:56
  • @Zen i 've shown the method in the first codeblock, and i only use it to pass the data. To check if it will be called i added a NSLog, but i don't get the output "[NewsPicture][connection]didReceiveData" for the first rows. – Dennis Peters Jul 05 '13 at 07:18
  • Yeah that i saw, but the url creation code looks fine and I was wondering if you checked for the response it gets. the `connection:didReceiveResponse` delegate gets called before the `didReceiveData:` gets called – Zen Jul 05 '13 at 07:30
  • @Zen Ok. Now i 've added the method and use a Log to check out if it is called, but i get the same result. Both methods would't be called for the first rows. (I added it in my post too.) – Dennis Peters Jul 05 '13 at 09:15

0 Answers0