Search code examples
iphoneuiimagepickercontroller

automatically start FrontCamera and capture image


I want to make a camera application in which i want to start front camera automatically and capture image without user interaction. thanks in advance.


Solution

  • I dont know how much you know about objective-c or iphone development.
    so I will tell how to take photos in your iphone app.
    First you should get your self aquatinted with UIImagePickerController class

    http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html

    here is some examples for the same from apple http://developer.apple.com/library/ios/samplecode/PhotoLocations/

    http://developer.apple.com/library/ios/samplecode/PrintPhoto/

    http://developer.apple.com/library/ios/samplecode/PhotoPicker/

    http://developer.apple.com/library/ios/samplecode/iPhoneCoreDataRecipes/

    and next here is the code that will help you take the pics if you just place it in your .m file

    - (void)selectPhotos
    {
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        picker.delegate = self;
        [self presentModalViewController:picker animated:YES];
        [picker release];
    }
    
    - (void)imagePickerController:(UIImagePickerController *)picker
            didFinishPickingImage:(UIImage *)image
                      editingInfo:(NSDictionary *)editingInfo
    {
        imageView.image = image;
        [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    }
    

    now get started.