2

I am making a custom photo picker. so i have used

imagePickerController.showsCameraControls = NO;

And i have created one camera overlay view and use

imagePickerController.cameraOverlayView = overlayView;

So, I need to implement custom button option, Can anyone please tell me how can i give customize button event using UIImagePickerController?

Thanks in advance.

Anand Gautam
  • 2,541
  • 3
  • 34
  • 70

1 Answers1

4

You can build a UIViewController, take it's view as the image picker's overlayView. All your custom buttons are controlled by this UIViewController.

e.g.

UIButton *myBtn = [[UIButton alloc] initWithFrame:btnFrame];

[myBtn addTarget:self action:@selector(myBtnPressed) forControlEvents:UIControlEventTouchUpInside];

[overlayView addSubview:myBtn];
Jing
  • 536
  • 3
  • 12
  • I have been using custom overlay for UIImagePickerController. I have added button so what event i need to use. – Anand Gautam May 31 '13 at 08:39
  • what do you mean "what event"? if you are in old version Xcode, you use .xib to custom your UI, else in storyboard. The point is , there should be one controller to take care for respond to user action. you can build a new controller to do it or use the one that UIImagePickerController lies in – Jing Jun 04 '13 at 07:07
  • @Jingdude.. i m not using any xib or storybaord . i have created custom buttons programmatically . – Anand Gautam Jun 04 '13 at 11:08
  • then you can use `addTarget:action:forControlEvents:` – Jing Jun 06 '13 at 06:03
  • e.g. `UIButton *myBtn = [[UIButton alloc] initWithFrame:btnFrame];` `[myBtn addTarget:self action:@selector(myBtnPressed) forControlEvents:UIControlEventTouchUpInside];` `[overlayView addSubview:myBtn];` – Jing Jun 06 '13 at 06:15
  • thanks ....Go to the below link and see my answer....i have solved....http://stackoverflow.com/questions/16933811/creating-a-preview-screen-with-a-custom-camera/16937825#16937825 – Anand Gautam Jun 06 '13 at 07:53
  • @AnandGautam I think this is what you were referring, Here is the take picture action you can call to take picture programmatically `[imagePickerController takePicture];` – Prasad De Zoysa Sep 05 '13 at 09:45
  • @PrasadYes, you are correct. but i was doing record in my app using [imagePickerController startVideoCapture]; – Anand Gautam Sep 05 '13 at 10:17