Hi all, first post here. I've been building apps for only a few weeks now but this is the first thing that's got me stumped!
I've added a custom overlay to a UIImagePickerController using the standard cameraOverlayView:
MainViewController.m
Code:
CameraOverlayView *overlay = [[CameraOverlayView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
picker.cameraOverlayView = overlay;
On the overlay I have a cancel button:
CameraOverlayView.m
Code:
UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
cancelButton.frame = CGRectMake(10, 10, 100, 40);
[cancelButton addTarget:self action:@selector(cancel:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:cancelButton];
My problem is that tapping the cancel button does nothing. I've coded it to dismiss the modal like other apps I've done
CameraOverlayView.m
Code:
- (IBAction) cancel:(id)sender {
[self.delegate cameraOverlayDidFinish:self];
}
which should run this:
MainViewController.m
Code:
- (void)cameraOverlayDidFinish:(CameraOverlayView *)cameraOverlayView
{
[self dismissModalViewControllerAnimated:YES];
}
But nothing happens, no errors, nothing logged to the console. Not a thing.
I think I may need to be calling
imagePickerControllerDidCancel like the standard picker uses, but if I change my cancelButton's selector to this it logs but then nothing either:
Code:
- (IBAction) cancel:(id)sender {
NSLog(@"cancel tapped");
[self.delegate imagePickerControllerDidCancel:(UIImagePickerController *)self];
}
Any help or suggestions would be very much appreciated, thanks!