Reputation: 263
I've seen many questions asked about how to add images to the simulator and have seen two answers:
Both worked great in everything previous to iOS SDK 4.0. Those same methods no longer work for me, and neither for anyone else that I have seen. I have tried to write an image to the photo library manually using the following chunk of code I found somewhere:
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
UIAlertView *alert;
if (error) // Unable to save the image
alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Unable to save image to Photo Album."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
else // All is well
alert = [[UIAlertView alloc] initWithTitle:@"Success"
message:@"Image saved to Photo Album."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}
But it errors every time. So is it a problem with the write access of the simulator? or just some bug? I have already updated to the iOS 4.1 SDK in hopes of it being fixed, but it isn't.
Upvotes: 7
Views: 5401
Reputation: 628
Very easy in Xcode 4.2 under OSX 10.6.8 :
1- Drag and drop any picture into the iphone simulator 2- when the picture shows up, RMC (RightMouseClick) and choose "Save Image" 3- back to the simulator´s desktop, choose "Photos" app and your picture/s will be there.
Upvotes: 0
Reputation: 21
I had the same problem running iOS Simulator 4.3 Using user44990 answer above fixed the problem for me and subsequently browsing in Safari and hold-click to save an image worked for me. I suspect the first step creates the proper directory: ~/Library/Application Support/iPhone Simulator/4.3.2/Media/DCIM/100APPLE which enable the click and hold method to work.
Upvotes: 2
Reputation: 348
I am using Xcode 3.2.4 with SDK 3.2, 4.0.1 and 4.1. The following steps worked for me: 1. Launch simulator 2. Drag an image from Finder to the simulator which will always launch Safari to show the image 3. CLICK and HOLD that click for a couple of seconds, then you will see a popup with a "Save Image" button
Upvotes: 16
Reputation: 113
This question is spot-on. All the current advice I've seen about dragging/dropping to Safari, creating DCIM\100APPLE, etc, are all ineffective in SDK 4.
Upvotes: 1