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