I am using UIImagePickerController with a custom overlay to record a video in my app. For the implementation of the UIImagePickerController, I have used the code from a grea
The problem is that the action you attach to the initWithBarButtonSystemItem
call doesn't pass the UIImagePickerController
instance along.
What I would do is set the UIImagePickerController as a property of your class and access that property from your action, like this:
In your .h:
@property (nonatomic, strong) UIImagePickerController *cameraUI;
In your .m:
- (BOOL) startCameraControllerFromViewController: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate {
...
self.cameraUI = [[UIImagePickerController alloc] init];
...
UIBarButtonItem *RecordBarButtonItem = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(recordPressed)]; // Removed the ':'
...
}
- (void) recordPressed {
NSLog(@"lets record");
[self.cameraUI startVideoCapture];
}
Actually I've just quickly tested it in some code I've gotten open, the sender
for your action on the button press is UIBarButtonItem *
. So there's a couple of things you can do, you can either go down the root of
UIBarButtonItem *senderButton = (UIBarButtonItem *)sender;
if(senderButton.image == UIBarButtonSystemItemCamera)
{
//Handle behaviour
}
Or set the tag
variable for each button and skip the image check and look at the tags instead, which might make the logic a bit easier.