iOS 相册

相机权限:Privacy - Camera Usage Description string: 是否允许此App使用你的相机?

相册权限:Privacy - Photo Library Usage Description string: 是否允许此App访问你的媒体资料库?

在info.plist加上这一条这样就可以使相册显示出中文

Localized resources can be mixed 设置为 YES。

//相册

- (void)photo{

//导入协议 <UIImagePickerControllerDelegate,UINavigationControllerDelegate>


UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];   

 [self presentViewController:imagePicker animated:YES completion:^{        imagePicker.delegate = self;        

imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 

   }];

}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary*)info

{

UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

self.imageView.image = image;

//返回图像修圆

//[self.imageView.layer setCornerRadius:CGRectGetHeight([self.hearView bounds])/2];

//self.imageView.layer.masksToBounds = YES;

[picker dismissViewControllerAnimated:YES completion:^{

//可使用通知传图片到上一页赋值

}];

}

//摄像头

- (void)camera

{

UIImagePickerController *imagePick = [[UIImagePickerController alloc] init];

[self presentViewController:imagePick animated:YES completion:^{

BOOL iscamera = [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear];

if (!iscamera) {

NSLog(@"没有摄像头");

return;

}

imagePick.delegate = self;

imagePick.sourceType = UIImagePickerControllerSourceTypeCamera;

//imagePick.allowsEditing = YES;

}];

}

//比较两张图片是否相似

NSData *data = UIImagePNGRepresentation(_hearView.image);

UIImage *image = [UIImage imageNamed:@"Photoicons@2x"];

NSData *data1 = UIImagePNGRepresentation(image);

if ([data isEqual:data1]) {

NSLog(@"-----------相似");

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容