I am trying to dynamically load an image in infowindow. The problem is that SDWebImage never terminates. However, as soon as I press the marker again, the image is displayed and ends, but not the first time. My log for "start" shows for the first time, so I know that the code is called, but the completion is never displayed on the first run, if the image is not cached, in which case it will be displayed at the second touch of the marker.
Side note: I keep the link to the image in the fragment because I have no other use.
Any ideas why SDWebImage is not complete? Or is there a better approach that others might think of?
The last thing I see in the blocks in the documentation says the following, which seems appropriate, but I don’t see how I cancel the request anyway to cause this behavior.
Note. none of your success or block failures will be triggered 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]){
tapped = NO;
return view;
}else{
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;
}
}
source
share