2

Is there a way to take a picture on the iPad without going through the Apple controls ? I have seen a bunch of apps that do this,

For example, when you add a new contact in iPhone, on the top left side it shows add photo when we click on that, camera opens up and it takes pic and saves to add photo..

I want to implement same functionality.. is it possible on iPad ?

tryKuldeepTanwar
  • 3,490
  • 2
  • 19
  • 49
Krunal
  • 6,440
  • 21
  • 91
  • 155

2 Answers2

3

What you need to do is , Add a button first, with the title "Add Photo" or with custom image.

Then on the click of the button add the following code :

    if (([UIImagePickerController isSourceTypeAvailable:
              UIImagePickerControllerSourceTypeCamera] == NO)
            return NO;

        UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
        cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController: cameraUI animated: YES completion:nil];

It will open up the camera, then you click the image and then tap "use" and You have to implement the UIImagePickerControllerDelegate method imagePickerController:didFinishPickingMediaWithInfo: and then store the UIImage to wherever you want, with whatever file name you want, using NSFileManager methods.

Rajan Balana
  • 3,775
  • 25
  • 42
  • Good ans it is working but, camera takes image bit after that it doesnot load my image which i have taken into `imageview` here is my code `- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissModalViewControllerAnimated:YES]; UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; [imgVw setImage:image]; imgVw.contentMode = UIViewContentModeScaleAspectFill; }` – Krunal Mar 25 '13 at 07:26
  • There might be some other problem I think, Because this code works completely fine at my end and it shows the image in the imageView also – Rajan Balana Mar 25 '13 at 07:29
1

Using image picker controller you can use the same functionality as you described in your question.

For that you need to convert the picture into image data & display it in uiimageview

You can refer this : UIImageView Class Reference

This will provide you examples too.

This answer of Taking a picture from the camera and show it in a UIImageView will provide you proper answer..

Enjoy Programming!!

Community
  • 1
  • 1
Niru Mukund Shah
  • 4,637
  • 2
  • 20
  • 34