티스토리 뷰

iOS/자료정리

[iOS]zBar 사용하기

썩소천사 2014. 2. 18. 19:31
반응형


[홈페이지]

http://zbar.sourceforge.net/iphone/index.html


[iOS7 대응]

http://blog.naver.com/wankil?Redirect=Log&logNo=40199872071


[자동스캔 시]

ZBarReaderViewController

[앨범이나 사진촬영 시]

ZBarReaderController



<개발 소스>


.h

#import "ZBarReaderController.h"

<ZBarReaderDelegate> 추가


.m

ZBarReaderViewController *reader = [[ZBarReaderViewController alloc] init];

reader.readerDelegate = self;

reader.showsZBarControls = NO;

reader.showsCameraControls = NO;

ZBarImageScanner *scanner = reader.scanner;

    [scanner setSymbology:ZBAR_I25

                   config:ZBAR_CFG_ENABLE

                       to:0];

    

    [self presentViewController:reader

                       animated:YES

                     completion:nil];


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

    id<NSFastEnumeration> scanResults =

[info objectForKey:ZBarReaderControllerResults];

    

    NSString *result;

    

    ZBarSymbol *symbol;

    for (symbol in scanResults)

    {

        result = [symbol.data copy];

        break;

    }

    NSLog(@"Result : %@", result);

    

    [self dismissViewControllerAnimated:YES completion:nil];

}


- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

{

NSLog(@"imagePickerControllerDidCancel ");

    [self dismissViewControllerAnimated:YES

                             completion:nil];

}


반응형
댓글
반응형