iOS开发中,获取图片之后保存或下载到本地相册中
#pragma mark 先获取本地图片或者网络图片
- (void)saveHeaderImageWith:(NSString *)path
{
UIImage *img = [UIImage imageWithContentsOfFile:path];
//这里img也可以是从网络获取的图片
[self saveImageToPhotos:img];
}
#pragma mark 保存图片
- (void)saveImageToPhotos:(UIImage*)savedImage
{
UIImageWriteToSavedPhotosAlbum(savedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
}
#pragma mark 系统的完成保存图片的方法
- (void)image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo
{
NSString *msg = nil ;
if (error != NULL) {
msg = @"保存图片失败" ;
} else {
msg = @"保存图片成功" ;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"保存图片结果提示" message:msg delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
} 相关推荐
好好学习天天 2020-07-21
heqiang0 2020-06-25
定格 2020-05-30
定格 2020-04-17
zhoutaifeng 2020-04-17
zhoutaifeng 2020-04-17
zhoutaifeng 2020-03-07
好好学习天天 2020-03-06
heqiang0 2020-03-02
知更鸟CoolLee 2020-02-27
发条戏子 2020-02-22
herogood 2020-02-19
好好学习天天 2020-02-17
heqiang0 2020-02-13
heqiang0 2019-12-12