私はアプリに ZXing を使用しています。これは、主に ZXing の元のコードと同じコードですが、連続して数回スキャンできることを除いて (つまり、何かが検出されるとすぐに ZXingWidgetController が破棄されるわけではありません)。
呼び出しを解除するボタンを押すと、長いフリーズが発生します (終了しない場合もあります)。
- (void)cancelled {
// if (!self.isStatusBarHidden) {
// [[UIApplication sharedApplication] setStatusBarHidden:NO];
// }
[self stopCapture];
wasCancelled = YES;
if (delegate != nil) {
[delegate zxingControllerDidCancel:self];
}
}
と
- (void)stopCapture {
decoding = NO;
#if HAS_AVFF
if([captureSession isRunning])[captureSession stopRunning];
AVCaptureInput* input = [captureSession.inputs objectAtIndex:0];
[captureSession removeInput:input];
AVCaptureVideoDataOutput* output = (AVCaptureVideoDataOutput*)[captureSession.outputs objectAtIndex:0];
[captureSession removeOutput:output];
[self.prevLayer removeFromSuperlayer];
/*
// heebee jeebees here ... is iOS still writing into the layer?
if (self.prevLayer) {
layer.session = nil;
AVCaptureVideoPreviewLayer* layer = prevLayer;
[self.prevLayer retain];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 12000000000), dispatch_get_main_queue(), ^{
[layer release];
});
}
*/
self.prevLayer = nil;
self.captureSession = nil;
#endif
}
(ビューを削除するdismissModalViewControllerはdelegateメソッド内にあることに注意してください)
iPhone 4 でのみ、連続して複数のスキャンを行った場合にのみ、閉じるときにのみフリーズが発生します (4S ではフリーズしません)。
何か案が ?
乾杯
ROM