-
Notifications
You must be signed in to change notification settings - Fork 7
Home
nrocy edited this page Sep 14, 2010
·
14 revisions
1. The camera is enabled by modifying the simulator plists.
2. A call is made to:
-(void)mockCameraWithImageURL:(NSString*)url delay:(NSInteger)delay;
This sets up an NSTimer that will fire after delay seconds. The timer handler will pull the image from the given URL, and present it to this delegate method:
- (void)imagePickerController:(UIImagePickerController *)thePicker didFinishPickingMediaWithInfo:(NSDictionary *)info
Locate the plist files for the simulator(s) that you want to change, for me these are:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/System/Library/CoreServices/SpringBoard.app/simulator.plist /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/CoreServices/SpringBoard.app/simulator.plist
As the iPad doesn’t have a camera it makes no sense to enable it – but if you want to, also change:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/CoreServices/SpringBoard.app/iPadSimulator.plist /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/System/Library/CoreServices/SpringBoard.app/iPadSimulator.plist
Open each of the plist files in the Property List Editor:
- Expand Root
- Add a new child to the capabilities dictionary, Key: “still-camera”, Type “Boolean”, Value: Ticked
- Save the plist file
You’ll probably need to copy the plist files somewhere else to be able to change them, then copy them back.
#ifdef DEBUG #import "UIImagePickerController+SimulatedCamera.h" #endif
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypeCamera; picker.showsCameraControls = YES; #ifdef DEBUG [picker mockCameraWithImageURL:@"http://localhost/test.jpg" delay:2.0]; #endif [self presentModalViewController:picker animated:YES]; [picker release];
The default delay is 2 seconds, if not specified.