Я сталкиваюсь с проблемой, которая кажется такой упрощенной и разочаровывающей.Я использую библиотеку zbar, чтобы поиграть со сканированием qr-кодов.Вот мой код:
- (IBAction)scanButtonTapped:(id)sender {
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
reader.showsZBarControls = NO;
UIButton *overlay = [UIButton buttonWithType:UIButtonTypeCustom];
overlay.frame = CGRectMake(0, 0, 320, 480);
[overlay setImage:[UIImage imageNamed:@"CameraCover.png"] forState:UIControlStateNormal];
reader.cameraOverlayView = overlay;
overlay.userInteractionEnabled = YES;
[overlay addTarget:self action:@selector(beginScanning:) forControlEvents:UIControlEventTouchUpInside];
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
// present and release the controller
[self presentModalViewController: reader
animated: NO];
[reader release];
}
- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
// ADD: get the decode results
id<NSFastEnumeration> results =
[info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
// EXAMPLE: just grab the first barcode
break;
// EXAMPLE: do something useful with the barcode data
resultText.text = symbol.data;
// EXAMPLE: do something useful with the barcode image
resultImage.image =
[info objectForKey: UIImagePickerControllerOriginalImage];
// ADD: dismiss the controller (NB dismiss from the *reader*!)
[reader dismissModalViewControllerAnimated: YES];
[self pushNewScreen];
}
-(void) pushNewScreen
{
MainViewController *mainView = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
[self presentModalViewController:mainView animated:YES];
[mainView release];
}
Проблема в том, что при вызове pushNewScreen mainView
не отображается ... Я прошел каждую строку с отладчиком, и каждая строка в pushNewScreen вызывается.Есть идеи?