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:
- -(Void) addPicEvent
- {
- // 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.
- UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
- If (! [UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
- SourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- }
- UIImagePickerController * picker = [[UIImagePickerController alloc] init];
- Picker. delegate = self;
- Picker. allowsEditing = YES;
- Picker. sourceType = sourceType;
- [Self presentModalViewController: picker animated: YES];
- [Picker release];
- }
- -(Void) saveImage :( UIImage *) image {
- NSLog (@ "save ");
- }
- # Pragma mark-
- # Pragma mark Camera View Delegate Methods
- -(Void) imagePickerController :( UIImagePickerController *) picker
- DidFinishPickingMediaWithInfo :( NSDictionary *) info {
- [Picker dismissModalViewControllerAnimated: YES];
- UIImage * image = [[info objectForKey: UIImagePickerControllerEditedImage] retain];
- [Self defined mselector: @ selector (saveImage :)
- WithObject: image
- Afterdelay: 0.5];
- }
- -(Void) imagePickerControllerDidCancel :( UIImagePickerController *) picker {
- [Picker dismissModalViewControllerAnimated: YES];
- }
Source code: http://easymorse-iphone.googlecode.com/svn/trunk/CameIphone/
Summary:IPhone application developmentUIImagePickerController call systemCameraI hope this article will help you!