#66 Too fast to dismiss

QR Code (4)

I found a bug in ZBarReaderViewController. Is a kind of ios bug.

What happens: The QRCode is too fast decoded!!

First I send a [myView presentModalViewController:vcBarCodeReaderView animated:YES];
The bug will only happens if I config the UIViewController with the slowest animation, this mean use
myView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal

Than it decoded the QRCode and call:
- (void)imagePickerController:(UIImagePickerController *)reader didFinishPickingMediaWithInfo:(NSDictionary*)info

In this function, I do a [zbarObject dismissModalViewControllerAnimated:YES]; and contiue my program. But because the QRCode was read and decoded before the animation finish, when I send a dismissModalviewController it not run!!

I don't know how to ckeck if the animation finish or if the dismissModalViewControllerAnimated really work. I know this function will be deprecated, and the new will use block. But I have to run it in old ios.

For me, to fix it, I do this codes:
@interface BBZBarReaderViewController : ZBarReaderViewController {
BOOL wasDismiss;
@property (assign) BOOL wasDismiss;
- (void)viewDidDisappear:(BOOL)animated;

@implementation BBZBarReaderViewController
@synthesize wasDismiss;
- (id)init{
wasDismiss = FALSE;
return [super init];

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
wasDismiss = FALSE;
return [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

- (void)viewDidDisappear:(BOOL)animated {
wasDismiss = TRUE;
[super viewDidDisappear:animated];

This mean, if the object call the viewDidDisappear, than the view was go out. I only have to check this. So in my program, I do this function:

- (void)checkIfDismiss

if (barCodeReaderView.wasDismiss==FALSE) {
[barCodeReaderView dismissModalViewControllerAnimated:YES];
[NSTimer scheduledTimerWithTimeInterval:0.3

And it work. What do you thing? Is important fix this in the codes? I can overwrite the function dismissModalViewControllerAnimated in the ZBarReaderViewController and call this function in loop until it pass in the viewDidDisappear. What do you like? This can be my first bug fix :)


Log in to post a comment.