Ok - I think it've got it:
Basically, I'm bypassing the header file entirely – instead instantiating the camera controller using objc_getClass.
My init code is thus:
Code:
self.cameraController = [(id)objc_getClass("PLCameraController") performSelector:@selector(sharedInstance)];
[cameraController setDelegate:self];
[cameraController setFocusDisabled:NO];
[cameraController setCaptureAtFullResolution:YES];
[cameraController setDontShowFocus:YES];
UIView *previewView = [cameraController performSelector:@selector(previewView)];
[containerView addSubview:previewView];
[cameraController performSelector:@selector(startPreview)];
sleep(2);
Note that cameraController is declared as (id), not as a class. Notice that I've been tinkering with some of the methods described in the header on the 3GS. They seem to be working and the log file doesn't indicate any unknown selectors. Also, I've found it necessary to sleep for a couple of seconds to allow the camera to initialise correctly (I suppose I should be handling this in the ReadyStateChanged delegate!)
I'm then taking the snapshot with a simple call:
Code:
[cameraController capturePhoto:TRUE];
My delegate routines are:
Code:
- (void)cameraControllerReadyStateChanged:(NSNotification *)aNotification
{
NSLog(@"cameraControllerReadyStateChanged: %@", aNotification);
}
-(void)cameraController:(id)sender
tookPicture:(UIImage*)picture
withPreview:(UIImage*)preview
jpegData:(NSData*)rawData
imageProperties:(struct __CFDictionary *)imageProperties
{
NSLog(@"Saving and re-initing...");
UIImageWriteToSavedPhotosAlbum(picture, self, @selector(imageSavedToPhotosAlbum: didFinishSavingWithError: contextInfo:), nil);
[cameraController performSelector:@selector(stopPreview)];
[cameraController performSelector:@selector(startPreview)];
}
-(void)cameraController:(id)sender
addedVideoAtPath:(NSString *)path
withPreviewSurface:(id)surface
metadata:(id)meta
wasInterrupted:(BOOL)interrupt
{
}
-(void)cameraController:(id)sender
modeDidChange:(int)mode {
NSLog(@"cameraController:modeDidChange");
}
-(void)cameraControllerVideoCaptureDidStart:(id)sender {
NSLog(@"cameraControllerVideoCaptureDidStart");
}
-(void)cameraControllerVideoCaptureDidStop:(id)sender {
NSLog(@"cameraControllerVideoCaptureDidStop");
}
-(void)cameraControllerFocusFinished:(id)sender {
NSLog(@"cameraControllerFocusFinished");
}
This works correctly - the tookPicture callback fires and the image is successfully saved to the 'Camera Roll' photo album. I managed to get the camera to re-init by stopping and starting the preview after the image is saved.
Some of those callback routines relating to video capture look intriguing. But what I've got so far has put me well on the way to getting my time-lapse photography app back and working!
Hope this helps you guys!
Cheers,
Chris