35

It seems obvious that some people have been able to figure out how to access the iPhone camera through the SDK (Spore Origins, for example). How can this be done?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Jason Francis
  • 1,104
  • 2
  • 14
  • 25

2 Answers2

48

You need to use the UIImagePickerController class, basically:

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = pickerDelegate
picker.sourceType = UIImagePickerControllerSourceTypeCamera

The pickerDelegate object above needs to implement the following method:

- (void)imagePickerController:(UIImagePickerController *)picker
           didFinishPickingMediaWithInfo:(NSDictionary *)info

The dictionary info will contain entries for the original, and the edited image, keyed with UIImagePickerControllerOriginalImage and UIImagePickerControllerEditedImage respectively. (see https://developer.apple.com/documentation/uikit/uiimagepickercontrollerdelegate and https://developer.apple.com/documentation/uikit/uiimagepickercontrollerinfokey for more details)

Cœur
  • 37,241
  • 25
  • 195
  • 267
wxs
  • 5,617
  • 5
  • 36
  • 51
  • The picker delegate method you mention here is now deprecated in OS 3.0 - http://tinyurl.com/yjlhzcl – barfoon Mar 01 '10 at 18:49
5

Hmmmm.....Ever tried using an OverlayView? With this the camera might look customized but in actuality its just a view above it.

If the private API's are directly accessed it might result in the app being rejected by Apple. See if the below link helps.

link text

binshi
  • 1,248
  • 2
  • 17
  • 33