Skip to content

Commit

Permalink
iPhone: fix several simulator-related bugs
Browse files Browse the repository at this point in the history
    - fix device property missing from simulated ZBarReaderView
    - fix AVCaptureDevice referenced from ZBarReaderViewController
    - fix simulated camera gesture multiple recognition
  • Loading branch information
spadix0 committed Jun 23, 2011
1 parent 7ad0b30 commit 48d7bc1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
6 changes: 6 additions & 0 deletions iphone/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
version 1.1.2:
* fix several simulator-related bugs
- fix device property missing from simulated ZBarReaderView
- fix AVCaptureDevice referenced from ZBarReaderViewController
- fix simulated camera gesture multiple recognition

version 1.1.1:
* fix ReaderSample project path to ZBarSDK
* README document new examples
Expand Down
8 changes: 7 additions & 1 deletion iphone/ZBarCameraSimulator.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,18 @@ - (void) setReaderView: (ZBarReaderView*) view
UILongPressGestureRecognizer *gesture =
[[UILongPressGestureRecognizer alloc]
initWithTarget: self
action: @selector(takePicture)];
action: @selector(didLongPress:)];
gesture.numberOfTouchesRequired = 2;
[view addGestureRecognizer: gesture];
[gesture release];
}

- (void) didLongPress: (UILongPressGestureRecognizer*) gesture
{
if(gesture.state == UIGestureRecognizerStateBegan)
[self takePicture];
}

- (void) takePicture
{
if(!picker) {
Expand Down
8 changes: 6 additions & 2 deletions iphone/ZBarReaderViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@
if(position < 0)
return(nil);

#if !TARGET_IPHONE_SIMULATOR
NSArray *allDevices =
[AVCaptureDevice devicesWithMediaType: AVMediaTypeVideo];
for(AVCaptureDevice *device in allDevices)
// FIXME how to quantify "best" of several (theoretical) possibilities
if(device.position == position)
return(device);
#endif
return(nil);
}

Expand Down Expand Up @@ -134,8 +136,10 @@ - (void) _init
cameraViewTransform = CGAffineTransformIdentity;

cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
AVCaptureDevice *device =
[AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeVideo];
AVCaptureDevice *device = nil;
#if !TARGET_IPHONE_SIMULATOR
device = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeVideo];
#endif
if(device)
cameraDevice = UICameraForAVPosition(device.position);
else
Expand Down
10 changes: 10 additions & 0 deletions iphone/ZBarReaderViewImpl_Simulator.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ - (void) dealloc
[super dealloc];
}

- (AVCaptureDevice*) device
{
return(nil);
}

- (void) setDevice: (AVCaptureDevice*) device
{
// simulated camera does nothing with this
}

- (void) updateCrop
{
previewImage.frame = preview.bounds;
Expand Down

0 comments on commit 48d7bc1

Please sign in to comment.