5

I'm trying to dynamically load an image into an infowindow. The issue is that SDWebImage doesn't ever complete. However, once I click the marker again the image shows and complete is called but never on the first time. My log for "run" shows on the first time so I know the code is being called but complete never shows on the first run unless the image is cached and in that case it will show on the second marker tap.

Side note: I'm storing the link to the image in snippet since I don't have another use for it.

Any ideas why SDWebImage doesn't complete? Or is there a better approach to this that anyone else can think of?

Last thing I see under blocks in documentation it says the following which seems to fit but I don't see how I'm canceling the request in anyway to cause this behavior.

Note: neither your success nor failure block will be call if your image request is canceled before completion.

bool tapped = NO;

-(BOOL) mapView:(GMSMapView *) mapVieW didTapMarker:(GMSMarker *)marker{
    tapped=YES;
    [mapVieW setSelectedMarker:marker];
    return YES;
}

- (UIView *)mapView:(GMSMapView *)mapVieW markerInfoWindow:(GMSMarker *)marker{
    if([marker.snippet isEqualToString:@""] || [marker.snippet isEqualToString:nil]){
        //no image
        tapped = NO;
        //code here
        return view;
    }else{
        //image
        //code for custom view which is unimportant
        if(tapped){
            NSLog(@"run");
            [image setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", URL_PREFIX, marker.snippet]] placeholderImage:[UIImage imageNamed:@"you"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
                NSLog(@"complete");
                tapped=NO;
                [mapView setSelectedMarker:nil];
                [mapView setSelectedMarker:marker];
            }];
        }
        return view;
    }
}
friedbunny
  • 2,421
  • 1
  • 23
  • 38
user577732
  • 3,956
  • 11
  • 55
  • 76
  • I have the same issue and couldn't resolve it so far. – SirKometa May 13 '14 at 13:17
  • @SirKometa neither have I it's quite the annoying issue but I think it definitely lies with SDWebImage so I'm going to create an issue on their github and possibly try out some other libraries – user577732 May 13 '14 at 16:46
  • I think that it might not be because of the SDWebImage. I have tested various async image loading libs(and native implementation) and neither has worked. Even my methods working in different places of the app does not work properly in the markerInfoWindow. Good luck! – SirKometa May 14 '14 at 10:43
  • @SirKometa thanks for the response I'm still going to try a few other libraries as well as my own methods and if I make a break through I'll be sure to let you know and hope you'll do the same for me – user577732 May 14 '14 at 17:32
  • normal value changes within completion block not working as well. – souvickcse Dec 23 '14 at 11:05

0 Answers0