开发者

iOS SDK 4.0 & 4.1 add images to simulator

开发者 https://www.devze.com 2023-01-07 19:50 出处:网络
I\'ve seen many questions asked about how to add images to the simulator and have seen two answers: Click and hold to save in Mobile Safari on the phone

I've seen many questions asked about how to add images to the simulator and have seen two answers:

  • Click and hold to save in Mobile Safari on the phone
  • Add the files to the 100Apple (or whatever) folder

Both worked great in everything previ开发者_开发知识库ous 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.


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


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消