我已经看到很多关于如何将图像添加到模拟器的问题,并且看到了两个答案:
>单击并按住以在手机上保存在Mobile Safari中
>将文件添加到100Apple(或其他)文件夹
两者都适用于iOS SDK 4.0之前的所有功能.那些相同的方法对我来说不再适用,也不适合我见过的任何人.我试图使用我在某处找到的以下代码块手动将图像写入照片库:
- - (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];
- }
但每次都会出错.那么模拟器的写访问是一个问题吗?还是只是一些bug?我已经更新到iOS 4.1 SDK,希望它被修复,但事实并非如此.
解决方法
我使用Xcode 3.2.4与SDK 3.2,4.0.1和4.1.以下步骤对我有用: 1.启动模拟器 2.将图像从Finder拖到模拟器,模拟器将始终启动Safari以显示图像 3.单击并按住单击几秒钟,然后您将看到一个带有“保存图像”按钮的弹出窗口