[iPhone] Uncovering the Secrets of UIImagePickerController Part 3

In the previous 2 posts, I talked about the secrets of view hierarchy and how to retrieve image from the UIImagePickerController. By understanding the internals of a UIImagePickerController, we are able to change some of the undocumented features. Steve Nygard has published an excellent class dumping utility. Eric Sadun‘s script make use of Steve’s class-dump to create a folder and fill it with header files from the iPhone’s private and public framework. I am going to share some of the information I have inferred from these header files.

The UIImagePickerController (PLCameraViewController) is a delegate of CameraView (/0/0/0). In the viewfinder mode, CameraView sends cameraViewCancelled: to its delegate when the Cancel button is pushed. If the Camera button is pushed, the following messages is sent in sequence: cameraViewShouldShowIris:, cameraViewShouldShowProgressWhileCapturing:, cameraViewShouldShowPreviewAfterSelection:. After “Use Photo” is pushed, cameraView:photoSaved: will be sent to its delegate. By using CameraView’s setDelegate:, you can assign a new delegate. I have successfully change the CameraView’s to my UIImagePickerController’s subclass. If you change the CameraView’s delegate, I will advice you to implement all 4 methods, and remember to forward these messages to the parent in these implementations.

In similar manner, cropOverlayWasCancelled:, cropOverlayWasOKed:, and cropOverlay:didFinishSaving: are sent to CameraView from PLCropLayer (/0/0/0/3). I guess you can customize the UI by playing with the (void)setShowsCropOverlay:(BOOL)fp8 and (void)setChangesStatusBar:(BOOL)fp8 methods in CameraView.

(void)setCropTitle:(id)fp8 subtitle:(id)fp12 buttonTitle:(id)fp16
looks interesting, but I can’t use it due to the limitation of NSObject’s performSelector. The titles (in view and buttons) can still be changed using the follow code:

There are more to be discovered, I leave the rest of the exploration to you.

Part 1 | Part 2

WARNING: Readers are adviced not to use the techniques presented in this 3 parts series. It is against the terms stated in the iPhone Developer Program. When undocumented features are used, the application may not work when a newer iPhone OS is released. DO IT AT YOUR OWN RISK.

Posted in Tao Of Programming at June 15th, 2009. No Comments.