gpt4 book ai didi

ios - 如何在iOS 6/7中将图像保存到相机胶卷/相册?

转载 作者:行者123 更新时间:2023-12-01 17:25:46 28 4
gpt4 key购买 nike

似乎大多数方法都指向UIImageWriteToSavedPhotosAlbum(),但是在iOS 6及更高版本中,您需要用户权限才能写入相机胶卷,因此,如果他们说“no”,我希望能够调用代码。

是否存在基于块的方法,该方法可让我在“失败”时调用代码?

最佳答案

检查一下

/* Save to the photo album */
UIImageWriteToSavedPhotosAlbum(imageToSave ,
self, // send the message to 'self' when calling the callback
@selector(thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:), // the selector to tell the method to call on completion
NULL); // you generally won't need a contextInfo here);

- (void)thisImage:(UIImage *)image hasBeenSavedInPhotoAlbumWithError:(NSError *)error usingContextInfo:(void*)ctxInfo {
if (error) {
// Do anything needed to handle the error or display it to the user
} else {
// .... do anything you want here to handle
// .... when the image has been saved in the photo album
}
}

关于ios - 如何在iOS 6/7中将图像保存到相机胶卷/相册?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21641038/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com