我想为Scan Books条形码创建应用程序,但是当我可以成功扫描条形码时,ZBarReaderViewController不会在imagePickerController中解除didFinishPickingMediaWithInfo委托并且我收到警告:
警告:尝试在演示文稿或解雇时从视图控制器中解除 正在进行中!
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
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
resultLable.text = symbol.data;
isbnResultString=symbol.data;
NSLog(@"isbnResultString-----%@",isbnResultString);
isbnLableText.text=isbnResultString;
NSLog(@"%@",[info objectForKey: UIImagePickerControllerOriginalImage]);
// EXAMPLE: do something useful with the barcode image
barCodeImageView.image=[info objectForKey: UIImagePickerControllerOriginalImage];
// ADD: dismiss the controller (NB dismiss from the *reader*!)
[self dismissViewControllerAnimated:YES completion:nil];
if (isbnResultString.length!=0)
{
if(![self connectedToInternet])
{
[appDelagate showActivityIndicator];
appDelagate.isNetConnected=NO;
[self internetAlert];
}
else
{
[self getBookDetailsByISBN:symbol.data];
}
}
}
如何解雇ZBarReaderViewController?
答案 0 :(得分:1)
有同样的问题和performSeletor:withObject:afterDelay:对我来说很好。
- (void)imagePickerController:(UIImagePickerController *)reader didFinishPickingMediaWithInfo:(NSDictionary *)info {
// do some userful stuff
[self performSelector:@selector(dismissZBar) withObject:nil afterDelay:1];
}
- (void)dismissZBar {
[self.presentedViewController dismissViewControllerAnimated:YES completion:^{
// do some stuff after dismiss
}];
}