2015-04-08 36 views
0

我想給RedLaser SDK添加到我的項目,並試圖打開PickerController我在得到一個錯誤時的原因:找不到崩潰

0x39b70538: push {r4, r5, r6, r7, lr}

這是我的代碼如何實例化PickerController

- (IBAction) redBoxScanButtonPressed 
{ 
    RLSampleViewControllerRequestVideoAuthorization(^void (void) { 

     RedBoxPickerController *redBoxPickerController = 
     [[RedBoxPickerController alloc] initWithNibName:@"RedBoxPickerController" bundle:nil]; 
     redBoxPickerController.delegate = self; 

     // hide the status bar and show the scanner view 
     [[UIApplication sharedApplication] setStatusBarHidden:YES]; 
     [self presentViewController:redBoxPickerController animated:NO completion:nil];// presentModalViewController:redBoxPickerController animated:FALSE]; 
     //[redBoxPickerController release]; 
    }); 
} 

方法來請求授權:

static void RLSampleViewControllerRequestVideoAuthorization(dispatch_block_t completionHandler) { 

    RL_RequestVideoAuthorization(^void (RL_VideoAuthorizationStatus status) { 

     if (status == RL_VideoAuthorizationStatusAuthorized) { 

      dispatch_async(dispatch_get_main_queue(), ^void (void) { 

       completionHandler(); 

      }); 

     } 

    }); 

} 

回溯

(lldb) bt 
* thread #11: tid = 0xc81db, 0x39b70538 libc++abi.dylib`__cxa_throw, queue = 'ZXing', stop reason = breakpoint 1.2 * frame #0: 0x39b70538 libc++abi.dylib`__cxa_throw 
    frame #1: 0x00187e32 IRON TRAINERS`zxing::GlobalHistogramBinarizer::estimate(std::vector<int, std::allocator<int> >&) + 370 
    frame #2: 0x00187f60 IRON TRAINERS`zxing::GlobalHistogramBinarizer::getBlackMatrix() + 268 
    frame #3: 0x00186580 IRON TRAINERS`zxing::BinaryBitmap::getBlackMatrix() + 12 
    frame #4: 0x001a9b00 IRON TRAINERS`zxing::qrcode::QRCodeReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 44 
    frame #5: 0x001b086e IRON TRAINERS`zxing::Reader::decode(zxing::Ref<zxing::BinaryBitmap>) + 278 
    frame #6: 0x001b4a86 IRON TRAINERS`-[FormatReader decode:] + 142 
    frame #7: 0x00185da8 IRON TRAINERS`-[ZXingDecoder findCodesInBitmap:bytesPerRow:width:height:] + 796 
    frame #8: 0x001ba93e IRON TRAINERS`-[BarcodePhotoEngine zxingFindBarcodesInPixmap:] + 226 
    frame #9: 0x001b318c IRON TRAINERS`__38-[BarcodeEngine findBarcodesInPixMap:]_block_invoke55 + 76 
    frame #10: 0x0081e172 libdispatch.dylib`_dispatch_call_block_and_release + 10 
    frame #11: 0x00826d66 libdispatch.dylib`_dispatch_queue_drain + 1718 
    frame #12: 0x00820a60 libdispatch.dylib`_dispatch_queue_invoke + 88 
    frame #13: 0x00828b08 libdispatch.dylib`_dispatch_root_queue_drain + 1308 
    frame #14: 0x00829e18 libdispatch.dylib`_dispatch_worker_thread3 + 100 
    frame #15: 0x3a91adc0 libsystem_pthread.dylib`_pthread_wqthread + 668 (lldb) 

我不知道要尋找什麼,我試圖添加幾個breakpoints,但沒有發現問題。

示例項目工作正常,所以我想我錯過了一些代碼。

這裏是PickerController的完整代碼:

/******************************************************************************* 
    RedBoxPickerController.m 
    Part of RLSample 

    This is a scan overlay example that frames discovered barcodes with red boxes. 

    Chall Fry 
    November 2012 
    Copyright (c) 2012 eBay Inc. All rights reserved. 
*/ 

#import "RedBoxPickerController.h" 


@implementation RedBoxPickerController 

/******************************************************************************* 
    didReceiveMemoryWarning 

*/ 
- (void) didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
} 

/******************************************************************************* 
    viewWillAppear: 

    Sets up the initial state of UI elements in the overlay. 
*/ 
- (void) viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 

    inRangeLabel.hidden = true; 
    numBarcodesFoundLabel.text = @""; 

    torchButton.enabled = self.hasTorch; 
    torchButton.style = self.isTorchOn ? UIBarButtonItemStyleDone : 
      UIBarButtonItemStyleBordered; 
} 

#pragma mark Button Handlers 

/******************************************************************************* 
    cancelScan 

    Action proc for the 'Done' button. 
*/ 
- (IBAction) cancelScan 
{ 
    [self doneScanning]; 
} 

/******************************************************************************* 
    captureImage 

    Action proc for the 'Cap' button. 
    Need to have reportCameraImage enabled for this. 
*/ 
- (IBAction) captureImage 
{ 
    if (!imageSaveInProgress) 
    { 
     [self requestCameraSnapshot:true]; 
     savingImageLabel.hidden = false; 
     captureButton.enabled = false; 
    } 
} 

/******************************************************************************* 
    toggleFrontBackCamera 

    Action proc for the 'Front/Back' button. 
*/ 
- (IBAction) toggleFrontBackCamera 
{ 
    self.useFrontCamera = !self.useFrontCamera; 
} 

/******************************************************************************* 
    toggleTorch 

    Action proc for the 'Light' button. 
*/ 
- (IBAction) toggleTorch 
{ 
    [self turnTorch:!self.isTorchOn]; 
    torchButton.style = self.isTorchOn ? UIBarButtonItemStyleDone : 
      UIBarButtonItemStyleBordered; 
} 

#pragma mark Status Updates 

/******************************************************************************* 
    statusUpdated: 

    The RedLaser SDK will call this method repeatedly while scanning for barcodes. 
*/ 
- (void) statusUpdated:(NSDictionary*) status 
{ 
    NSSet *foundBarcodes = [status objectForKey:@"FoundBarcodes"]; 

    // Report how many barcodes we've found so far 
    numBarcodesFoundLabel.text = [NSString stringWithFormat:@"%d Barcodes found", 
      [foundBarcodes count]]; 

    // Show the right guidance string for the guidance level 
    // Guidance is used for detecting long Code 39 codes in parts. 
    // See the documentation for more info. 
    int guidanceLevel = [[status objectForKey:@"Guidance"] intValue]; 
    if (guidanceLevel == 1) 
    { 
     guidanceLabel.text = @"Try moving the camera close to each part of the barcode"; 
    } else if (guidanceLevel == 2) 
    { 
     guidanceLabel.text = [NSString stringWithFormat:@"%@…", 
       [status objectForKey:@"PartialBarcode"]]; 
    } else { 
     guidanceLabel.text = @""; 
    } 

    // Show the in range label if we're in range of an EAN barcode 
    inRangeLabel.hidden = ![[status objectForKey:@"InRange"] boolValue]; 

    // Tell the Red Box View to update its display 
    redBoxView.barcodes = foundBarcodes; 
    [redBoxView setNeedsDisplay]; 

    // If the user clicked the "Capture" button, this key will have a UIImage in it 
    // on a subsequent statusUpdated call. Otherwise, the key won't be present. 
    // If we have a camera image, save it to the device's photo album. 
    UIImage *cameraImage = [status objectForKey:@"CameraSnapshot"]; 
    if (cameraImage && cameraImage != (id) [NSNull null]) 
    { 
     imageSaveInProgress = true; 

     UIImageWriteToSavedPhotosAlbum(cameraImage, self, 
       @selector(image:didFinishSavingWithError:contextInfo:), nil); 
    } 
} 

/******************************************************************************* 
    image:didFinishSavingWithError:contextInfo: 

    Called when UIImageWriteToSavedPhotosAlbum() has finished saving an image to 
    the camera roll. 

    Reenables the Capture button and hides the "Saving Image..." label. 
*/ 
- (void) image: (UIImage *) image didFinishSavingWithError: (NSError *) error 
     contextInfo: (void *) contextInfo 
{ 
    imageSaveInProgress = false; 
    savingImageLabel.hidden = true; 
    captureButton.enabled = true; 
} 

@end 

@implementation RedBoxView 

@synthesize barcodes; 

/******************************************************************************* 
    drawRect: 

    RedBoxView is a UIView subclass that exists to override this method. 

    When it redraws itself, it looks for any barcodes in the found barcode set that 
    have been 'seen' in the last second, makes a UIBezierPath from the corner 
    locations of the barcode, and then fills and strokes the path. 
*/ 
- (void) drawRect:(CGRect)rect 
{ 
    for (BarcodeResult *val in self.barcodes) 
    { 
     // Has this barcode been seen on-screen recently, or is it stale? 
     if ([val.mostRecentScanTime timeIntervalSinceNow] < -1.0) 
     { 
      continue; 
     } 

     // Don't bother displaying a path that only has 2 points--this is rare but can happen 
     if ([val.barcodeLocation count] < 2) 
      continue; 

     // Generate a UIBezierPath of the points, close it, and fill it 
     UIBezierPath *path = [UIBezierPath bezierPath]; 
     [path moveToPoint:[[val.barcodeLocation objectAtIndex:0] CGPointValue]]; 
     for (int index = 1; index < [val.barcodeLocation count]; ++index) 
     { 
      [path addLineToPoint:[[val.barcodeLocation objectAtIndex:index] CGPointValue]]; 
     } 
     [path closePath]; 

     [[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.2] set]; 
     [path fill]; 

     [[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.3] set]; 
     [path stroke]; 
    } 

    // Be sure to clear out the barcodes once we've drawn them 
    self.barcodes = nil; 
} 

- (void) didMoveToSuperview 
{ 
    CGRect superviewFrame = [[self superview] frame]; 
    superviewFrame.origin.x = superviewFrame.origin.y = 0; 
    self.frame = superviewFrame; 
    [super didMoveToSuperview]; 
} 


@end 

回答

1

您可以「啓用殭屍對象」在你的應用方案。這會給你適當的錯誤信息。

只需點擊您的應用程序名稱(xCode上停止按鈕的右側),然後單擊編輯方案,然後單擊左側面板中的RUN現在轉到「診斷」選項卡,您將看到內存管理標題,您可以在其中啓用「啓用殭屍對象」。

希望這會幫助你。

+0

謝謝,這是一個很好的建議,雖然它沒有顯示任何消息。 – Jorge

相關問題