IOS截图保存到相册

通过Creator已经成功截图并且保存到应用的路径,但是怎么样才能保存到相册啊?有没有哪位IOS开发的大神给个可以移动相片到相册的思路啊?IOS开发完全小白,安卓已经成功保存到相册。

+(void)setFileToLocal:(NSString*)path
{
@try {
if (![NSString isNullOrEmpty:path]) {
UIImage *image = [UIImage imageWithContentsOfFile:path]; // 取得图片
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
}
} @catch (NSException *exception) {
NSLog(“保存图片错误!”);
}

}

把保存的路径传过来就ok了 我这边试了是可以的

4赞

谢谢,测试可以用!

楼主,你好,安卓是怎么做的,先保存到com.game下,然后通过安卓原生代码去拷贝吗

官方例子中已经把图片存到应用可以保存的位置,在安卓中增加以下方法,通过图片的路径把图片保存到相册

// 获取 路径中的图片 保存到本地
public static void saveTextureToLocal( String pngPath) {
    //从路径中读取 照片
    Bitmap bmp = BitmapFactory.decodeFile(pngPath);

    // fileName ==textureName  尽量和JS保存的一致
    String fileName = "textureName";
    File file = new File(pngPath);
    try {
        FileOutputStream fos = new FileOutputStream(file);
        bmp.compress(Bitmap.CompressFormat.PNG, 100, fos);
        fos.flush();
        fos.close();

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    // 其次把文件插入到系统图库
    try {
        MediaStore.Images.Media.insertImage(AppActivity.getContext().getApplicationContext().getContentResolver(),
                file.getAbsolutePath(), fileName, null);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    // 最后通知图库更新
    AppActivity.getContext().getApplicationContext().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse(file.getAbsolutePath())));

}
2赞

iOS保存到应用的路径这一步,你是怎么做的?