iOS长按识别图中二维码

直接上代码  基于 zbar

#pragma mark -------判断是否为二维码
- (void)isPinCodeWithImage:(UIImage *)image{
    ZBarReaderController* read = [ZBarReaderController new];
    CGImageRef cgImageRef = image.CGImage;
    ZBarSymbol* symbol = nil;
    for(symbol in  [read scanImage:cgImageRef])
        break;
    _pincodeURL = symbol.data;
    UIActionSheet *actionSheet;
    if ([symbol.data hasPrefix:@"http"]) {
        actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"保存图片" otherButtonTitles:@"扫二维码", nil];
    } else {
       actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"保存图片" otherButtonTitles:nil, nil];
    }
    [actionSheet showInView:self.superview];
}
出来 CSDN  多多支持

你可能感兴趣的:(iOS)