-
-
Save qy1010/c3389096fba89ec56296cf2198109e82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//保存图片到相册 | |
//image是要保存的图片 | |
- (void) saveImage:(UIImage *)image{ | |
if (image) { | |
UIImageWriteToSavedPhotosAlbum(image, self, @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil); | |
}; | |
} | |
//保存完成后调用的方法 | |
- (void) savedPhotoImage:(UIImage*)image didFinishSavingWithError: (NSError *)error contextInfo: (void *)contextInfo { | |
if (error) { | |
NSLog(@"保存图片出错%@", error.localizedDescription); | |
} | |
else { | |
NSLog(@"保存图片成功"); | |
} | |
} | |
// 2.保存视频到相册 | |
//videoPath为视频下载到本地之后的本地路径 | |
- (void)saveVideo:(NSString *)videoPath{ | |
if (_videoPath) { | |
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum([_videoPath path])) { | |
//保存相册核心代码 | |
UISaveVideoAtPathToSavedPhotosAlbum([_videoPath path], self, @selector(video:didFinishSavingWithError:contextInfo:), nil); | |
} | |
} | |
} | |
//保存视频完成之后的回调 | |
- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { | |
if (error) { | |
NSLog(@"保存视频失败%@", error.localizedDescription); | |
} | |
else { | |
NSLog(@"保存视频成功"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment