//長按事件
-(void)longShowImageAction:(UILongPressGestureRecognizer *)sender{
UIImageView * disImageView = (UIImageView *)sender.view;
if (disImageView.image) {
//1. 初始化掃描儀,設置設別類型和識別質量
CIDetector*detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{ CIDetectorAccuracy : CIDetectorAccuracyHigh }];
//2. 掃描獲取的特征組
NSArray *features = [detector featuresInImage:[CIImage imageWithCGImage:disImageView.image.CGImage]];
//3. 獲取掃描結果
CIQRCodeFeature *feature = [features objectAtIndex:0];
NSString *scannedResult = feature.messageString;
DBLog(@"掃描到的結果? %@",scannedResult);
//如果掃描到的結果是url,這里是直接在瀏覽器中打開掃描的url,如果不是,可以判斷一下,讓去做其他的事情
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:scannedResult]];
}
}