現(xiàn)在的app對二維碼的使用越來越頻繁了,幾乎每個App都有這個功能,而在iOS8之前想要識別系統(tǒng)相冊中的二維碼,只能使用第三方,iOS8之后系統(tǒng)加入的原生識別二維碼的方式,很簡單
需要先聲明代理方法
@interface ViewController ()<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
UIImagePickerController *imagrPicker = [[UIImagePickerController alloc]init]; imagrPicker.delegate = self; imagrPicker.allowsEditing = YES; //將來源設置為相冊 imagrPicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; [self presentViewController:imagrPicker animated:YES completion:nil];
代理方法
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{ //獲取選中的照片 UIImage *image = info[