我正在使用ZBar,我正在尝试添加子视图以在扫描条形码之后和我的新视图准备就绪之前显示搜索UIActivityIndicatorView(慢速Web查找等)。这是代码:
- (IBAction)scanImage{
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
// (optional) additional reader configuration here
[scanner setSymbology: ZBAR_ISBN13 & ZBAR_ISBN10
config: ZBAR_CFG_ENABLE
to: 1];
// present and release the controller
[self presentViewController:reader animated:YES completion:NULL];
}
- (IBAction)existingImage {
ZBarReaderController *reader = [ZBarReaderController new];
reader.readerDelegate = self;
reader.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[reader.scanner setSymbology: ZBAR_ISBN13 & ZBAR_ISBN10
config: ZBAR_CFG_ENABLE
to: 1];
[self presentViewController:reader animated:YES completion:NULL];
}
- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
[reader dismissViewControllerAnimated:YES completion:NULL];
[reader.view addSubview:loading];
...
问题在于最后两个陈述。读取器视图控制器在执行segue时直到稍后在冷块中才被解除,并且不会显示“加载”子视图(代码中较早的设置)。我可以使用代码来表明加载是合法的,但我不能让它出现在我想要的时候。屏幕只显示摄像机视图或现有图像的图片,我可以看到控制台日志中发生的所有segue设置活动,然后使用我的segue'ed视图控制器更新视图。 FWIW我需要iOS6,这就是为什么我使用dismissViewControllerAnimated:而不是dismissModalViewController:但我还是尝试了它,但它没有用。
非常感谢任何建议!