从群聊天记录中保存到微信视频保存系统相册册的视频与照片去那里拿?

调用系统相册或系统相机,用到的是**UIImagePickerController**。要遵循两个协议UIImagePickerControllerDelegate,UINavigationControllerDelegate。
具体代码如下:
调用相册:
self.imagePicker = [[UIImagePickerController alloc]init];
self.imagePicker.allowsEditing = YES;
self.imagePicker.delegate = self;
self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoL
self.imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:self.imagePicker animated:YES completion:nil];
在上面的sourceType分为三种:
typedef NS_ENUM(NSInteger, UIImagePickerControllerSourceType) {
UIImagePickerControllerSourceTypePhotoLibrary,
UIImagePickerControllerSourceTypeCamera,
UIImagePickerControllerSourceTypeSavedPhotosAlbum
} __TVOS_PROHIBITED;
当调用系统相机时,使用UIImagePickerControllerSourceTypeCamera这个类型
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeC
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[self showHUDMessage:@"相机不可用"];
self.imagePicker = [[UIImagePickerController alloc]init];
self.imagePicker.allowsEditing = YES;
self.imagePicker.delegate = self;
self.imagePicker.sourceType = sourceT
self.imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:self.imagePicker animated:YES completion:nil];
实现代理方法:
pragma mark - ****************
选择图片回调方法
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary&NSString *,id& *)info{
UIImage *image = info[UIImagePickerControllerEditedImage];
_lostImageView.image =
[self dismissViewControllerAnimated:YES completion:nil];
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[self dismissViewControllerAnimated:YES completion:nil];
pragma mark 获取沙盒中完整的文件路径
-(NSString *)getFilePath:(NSString *)fileName{
NSString *fileP
NSArray *docPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *docPath = docPaths[0];
filePath = [docPath stringByAppendingPathComponent:fileName];
NSLog(@"filePath:%@",filePath);
return fileP
-(void)writeImageToDocPathsWith:(NSString *)imageName{
NSFileManager *fileManager = [NSFileManager defaultManager];
_filePath = [self getFilePath:[NSString stringWithFormat:@"%@.png",imageName]];
if (![fileManager fileExistsAtPath:_filePath]) {
[fileManager createFileAtPath:_filePath contents:nil attributes:nil];
NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:_filePath];
NSData *fileData = UIImagePNGRepresentation(_lostImageView.image);
[fileHandle seekToEndOfFile];
[fileHandle writeData:fileData];
[fileHandle closeFile];
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:13104次
排名:千里之外
原创:29篇
/goingmyway1
(4)(6)(2)(7)(6)(4)(1)洛阳雅香楼月饼洛阳美伦实业有限公司90视觉小川国际婚纱摄影老酒商行洛阳睿智朗文培训学校
原价:¥ 5000
才990克 军工 原装正品松下 T1 T2 迅驰 二手笔记本电
原价:¥ 3999
宏基/acer AO532h 超薄10寸上网本N450 笔记本全国联保
原价:¥ 2999
新迈腾售19.98万起
&&&&作为最新一代大众B级车的全新迈腾,于日在国内正式投放上市...
? ? ? ? ? ? ? ?
火车票查询
身份证查询
驾驶员违法信息查询
驾驶证号:
档案编号:
验 证 码:
机动车违法信息查询
号牌种类:
两、三轮摩托车
轻便摩托车
使馆摩托车
领馆摩托车
境外摩托车
外籍摩托车
农用运输车
教练摩托车
试验摩托车
临时入境汽车
临时入境摩托车
临时行驶车
原农机号牌
号牌号码:
发动机号:
验 证 码:
<option value="800:9元以上
? ? ?? ? ?
? ? ? ? ? ?
洛阳全聚德大酒店
&&&&“牡丹燕菜”,是一道具有豫西地方特色的佳肴...
适合于中小型企业建立标准网站,页面设计精美、动…
适用于小型企业,建立成本低的小型宣传网站网站价…
功能全面、界面美观、后台管理、信息量大、专业的…
服务及其他

我要回帖

更多关于 iphone已保存系统相册 的文章

 

随机推荐