简体   繁体   中英

always returns nil in iPhone

I am trying to apply Mike Chen's answer here , using SDK 3.0. In delegate.m file I implement;

[viewController.view addSubview:[[objc_getClass("PLCameraController") sharedInstance] previewView]];

and in viewcontroller.m I implement:

PLCameraController *cam = [objc_getClass("PLCameraController") sharedInstance];
CapturedImage = [cam _createPreviewImage];

but 'cam' is always nil. Any suggestions?

This won't work when running in the simulator or on an iPod Touch. Are you running this on a physical iPhone with a camera?

Also, if you've dumped the headers correctly, you shouldn't be using the objc_ runtime functions, but rather using the class names. Is the result of objc_getClass("PLCameraController") set to nil ?

On a side note: I hope you're not looking to publish your application through the App Store because this sort of private method calling is a great excuse for Apple to reject your application.

To use PLCameraController, you'll need to include the PhotoLibray private framework. The simplest way to do that is drag drop an Image Picker Controller (UIImagePickerController) into your main nib.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM