"invalid image size" error


Going through the Whereami example app, I’ve just added the line to mark my current location:

The pin appears, but I get this error in the console:

And as a result of this error, mapView:didAddAnnotationViews isn’t firing (a log statement I’ve got in there isn’t showing). Any idea what this error might be? FWIW, I’m using the iOS4 SDK.



There is a bug in SDK 4.0 that prints out that invalid image string when MapKit is placing an annotation - but, it should not prevent the delegate message to be sent.

Make sure you have no typos in the method (copy and pasting from the documentation is the best way to do this) and that the delegate pointer of the mapView is set to your application delegate.


I hadn’t set the MapView’s delegate pointer. All better. Thanks, Joe!


I’m having the same problem, but my code seems to be fine. It causes whatever I type in the text field to simply put the app into a perpetual load state. The text box is hidden and the activity indicator spins on and on. Am I missing the same thing the Greenideas did?


Also having the same issue here, checked the code and connections, everything looks ok. I also put an NSLog in the Annotation call and it never shows in the log. I also get the ‘CGImaeCreateWithImageProvider: invalid image size: 0 x 0’ error.


Make sure that the connection goes both ways for the map view: mapView outlet from WhereamiAppDelegate to MKMapView on the Window and delegate outlet from MKMapView to WhereamiAppDelegate.

Double check there are no typos or capitalization errors in the method name either, you can do this by copying from the documentation.


I checked all the connections and they are good. I also copied both the below methods from the documentation:

  • (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation

  • (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

And rechecked all the code but I am still getting the same error. Is the source for this chapter posted on here somewhere, maybe I could copy and paste the entire program and see what my results are.



The source is at bignerdranch.com/solutions/i … amming.zip.

But, those two methods you just listed are for the location manager. I thought your problem was that the MKMapView delegate method for annotations wasn’t getting called?

The “CGImageCreateWithImageProvider error” print out will be there always, its not really an error.


Thanks Joe!

I copied the code from the documentation but I didn’t copy the ‘mapView’ method because I thought I was getting that error and it wasn’t calling the method. Well low and behold it was calling it and there was something missing. I don’t know how many times you can look at some code and not see three letters missing!

Feeling kind of foolish here at this point.

Thanks again,

// My incorrect code

-(void)mapView:(MKMapView *)mv didAnnotationViews:(NSArray *)views
NSLog(@“Annontation Called”);
MKAnnotationView *annotationView = [views objectAtIndex:0];
id mp= [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 250, 250);
[mv setRegion:region animated:YES];

// The correct code from the source download

  • (void)mapView:(MKMapView *)mv did[color=#FF0000]Add[/color]AnnotationViews:(NSArray *)views
    MKAnnotationView *annotationView = [views objectAtIndex:0];
    id mp = [annotationView annotation];
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 250, 250);
    [mv setRegion:region animated:YES];


It gets everyone from time to time. One quick way to check to make sure you at least have the name of the method correct is to cmd-option-double click on the method name. If it appears in the documentation, and it still isn’t getting called, check for capitalization errors and make sure the proper outlets are connected. Of course, if it doesn’t appear in the documentation (the outcome in your situation), you know you have the wrong method implemented. :slight_smile:



I’m having the same error as above. My method names appear to be correct and I double checked the connections in Interface Builder. I have downloaded your provided solution and it produces the same error that my code does for me.

Whereami[1501] : CGImageCreateWithImageProvider: invalid image size: 0 x 0.
Whereami[1501:207] <+39.78329292, -84.06011501> +/- 153.00m (speed -1.00 mps / course -1.00) @ 2011-01-18 21:20:42 GMT
Whereami[1501:207] Could not find location: Error Domain=kCLErrorDomain Code=0 “The operation couldn’t be completed. (kCLErrorDomain error 0.)”

I’m using Xcode 3.2.4 and the iPhone Simulator 4.1.

Any ideas?



the same as previous post… everything seemts to be correct! any help would be greatly appreciated