Search This Blog

Monday, 24 September 2012

How to integrate camera in xcode

Hello friends,
               Long time na???? actually i dint do anything new in these last days i surely made sketch book for kids on iPhone but not something great....apart from all that , here it is a simple yet useful code for you....


CODE:

start camera on button click:

In a button click function :

UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
 
 
Remember i m not releasing the imagePicker as i use ARC in my projects ...
 
 
Now get the image captured in UIImage...override this function and remember 
to mention UIImagePickerControllerDelegate in your header file..
 
- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info {
    UIImage * image = [info objectForKey:UIImagePickerControllerEditedImage];

    // You have the image. You can use this to present the image in the 
       next view like you require in `#3`.

    [self dismissModalViewControllerAnimated:YES];
}
 
 
Ask for any queries.....
 
This can lead you to new ideas....sorry for being selfish i can't tell
 you my idea, but presently i m using this simple thing to make something 
that never comes to itunes before.

No comments:

Post a Comment