UIImagePickerControllerEditedImage];
if (!image) { image = info[
UIImagePickerControllerOriginalImage]; }
CIDetector *detector = [
CIDetector detectorOfType:
CIDetectorTypeQRCode context:
nil options:
nil]; [picker dismissViewControllerAnimated:
YES completion:^{
NSArray *features = [detector featuresInImage:[
CIImage imageWithData:
UIImagePNGRepresentation(image)]];
if (features.count >=
1) {
CIQRCodeFeature *feature = features[
0];
NSString *scannedResult = feature.messageString; [
self alertControllerMessage:scannedResult]; }
else{ [
self alertControllerMessage:
@"这不是一个二维码"]; } }];}-(
void)alertControllerMessage:(
NSString *)message{
UIAlertController *alert = [
UIAlertController alertControllerWithTitle:
@"" message:message preferredStyle:
UIAlertControllerStyleAlert];
UIAlertAction *action = [
UIAlertAction actionWithTitle:
@"cancel" style:
UIAlertActionStyleCancel handler:^(
UIAlertAction * _Nonnull action) { }]; [alert addAction:action]; [
self presentViewController:alert animated:
YES completion:
nil];}
2/3 首页 上一页 1 2 3 下一页 尾页