I have some code which works on iPhone 5 but not on iPhone 5S or iPad Air. I know that the iPhone 5 is 32 bit and the other devices are 64 bit, but I can't see how this would cause my problem. I use a camera overlay with a button on a tabbar to capture my picture.
I can instantiate the UIImagePickerController like so:
UIImagePickerController *pick = [[UIImagePickerController alloc] init];
pick.modalPresentationStyle = UIModalPresentationCurrentContext;
pick.sourceType = UIImagePickerControllerSourceTypeCamera;
pick.delegate = self;
pick.wantsFullScreenLayout=YES;
/*
The user wants to use the camera interface. Set up our custom overlay view for the camera.
*/
CGSize screenBounds = [UIScreen mainScreen].bounds.size;
CGFloat cameraAspectRatio = 4.0f/3.0f;
CGFloat camViewHeight = screenBounds.width * cameraAspectRatio;
CGFloat scale = screenBounds.height / camViewHeight;
pick.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenBounds.height - camViewHeight) / 2.0);
pick.cameraViewTransform = CGAffineTransformScale(pick.cameraViewTransform, scale, scale);
pick.showsCameraControls = NO;
/*
Load the overlay view from the OverlayView nib file. Self is the File's Owner for the nib file, so the overlayView outlet is set to the main view in the nib. Pass that view to the image picker controller to use as its overlay view, and set self's reference to the view to nil.
*/
[[NSBundle mainBundle] loadNibNamed:IS_IPAD ? @"OverlayView-ipad" : @"OverlayView" owner:self options:nil];
self.overlayView.frame = pick.cameraOverlayView.frame;
self.focusRect.layer.borderColor = [UIColor colorWithRed:255 green:0 blue:0 alpha:1.0].CGColor;
pick.cameraOverlayView = self.overlayView;
self.overlayView = nil;
self.imagePickerController = pick;
[self presentViewController:self.imagePickerController animated:YES completion:nil];
The focusRect is a Red rectangle on the view to show users how to center their photo.
I have added the protocols to my .h file: UIImagePickerControllerDelegate, UINavigationControllerDelegate
I call takePicture with an IBAction. The following works on 32 bit, but not 64:
- (IBAction)takePicture:(id)sender{
[self.imagePickerController takePicture];
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *chosenImage = info[UIImagePickerControllerOriginalImage]; //64 bit never gets here
//Do some stuff.
}
The symptoms are just that neither didFinishPickingMediaWithInfo nor imagePickerControllerDidCancel ever get executed on 64 bit devices. My overlay is dismissed, but the code in these methods only executes on 32 bit devices.
I have checked several other questions and answers, for example this. Several suggestions from different threads were to make sure that the delegate is being set to self, adding the proper protocols to the view, and making sure the method name is typed correctly. I believe that these are covered.
I have confirmed that the app is running as 32 bit. Due to a dependency, I have the Valid Architectures set to "arm7 arm7s" without arm64. I am using XCode5.I would appreciate any help you can offer. Thank you for looking.