Call System camera for iPhone application development

Source: Internet
Author: User

IPhone application developmentUIImagePickerController call systemCameraIt is the content to be introduced in this article. Let's look at the content. The iphone api provides a calling system.CameraInterface, we only need to call the corresponding interface, and immediately obtain the camera image in our program. Below is a very simple call systemCameraExample.

The corresponding interface is as follows:

 

 

Finally, you can edit the image and use the corresponding image.

The following is the main code:

 
 
  1. -(Void) addPicEvent
  2. {
  3. // Set sourceType to the camera and then determine whether the camera is available for ipod.) If no camera is available, sourceType cannot be set to a photo library.
  4. UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
  5. If (! [UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
  6. SourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  7. }
  8. UIImagePickerController * picker = [[UIImagePickerController alloc] init];
  9. Picker. delegate = self;
  10. Picker. allowsEditing = YES;
  11. Picker. sourceType = sourceType;
  12. [Self presentModalViewController: picker animated: YES];
  13. [Picker release];
  14. }
  15. -(Void) saveImage :( UIImage *) image {
  16. NSLog (@ "save ");
  17. }
  18. # Pragma mark-
  19. # Pragma mark Camera View Delegate Methods
  20. -(Void) imagePickerController :( UIImagePickerController *) picker
  21. DidFinishPickingMediaWithInfo :( NSDictionary *) info {
  22. [Picker dismissModalViewControllerAnimated: YES];
  23. UIImage * image = [[info objectForKey: UIImagePickerControllerEditedImage] retain];
  24. [Self defined mselector: @ selector (saveImage :)
  25. WithObject: image
  26. Afterdelay: 0.5];
  27. }
  28. -(Void) imagePickerControllerDidCancel :( UIImagePickerController *) picker {
  29. [Picker dismissModalViewControllerAnimated: YES];
  30. }

Source code: http://easymorse-iphone.googlecode.com/svn/trunk/CameIphone/

Summary:IPhone application developmentUIImagePickerController call systemCameraI hope this article will help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.