Damn, this blog is all about development nowadays, and to think, I told one guy I didn’t want to put his blog on my blogroll because it mostly had development stuff. Actually all it had was his “portfolio” of websites/apps he made, not bad, but not really a blog. So I said no. So he got offended. Eh, bite me, you SEO-weenie.
Well to get back to the point, like Erica, I hate the fact that the user has to click touch “Take Photo” to take a picture. I looked ather instructions, and after some a lot of struggling managed to get it to work.
But a problem was, the camera overlay would return if one returns to the camera view after leaving it, so I realized it had to go into its own view controller.
I tried improving it today, and it was really simple!
In the .h file:
@interface MyImagePickerController : UIImagePickerController {
// Empty
}
@end
And in the .m file:
@implementation MyImagePickerController
- (void) viewDidAppear: (BOOL)animated {
[super viewDidAppear:animated];
UIView *plCameraView = [[[[[[self.view subviews] objectAtIndex:0] subviews] objectAtIndex:0] subviews] objectAtIndex:0];
// [[[plCameraView subviews] objectAtIndex:3] removeFromSuperview];
[[[plCameraView subviews] objectAtIndex:3] setHidden:YES];
}
Initializing is just like before:
MyImagePickerController *imagePickerController = [[MyImagePickerController alloc] init]; imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
And to capture the preview, e.g. with an NSTimer (I haven’t looked up how to fake the clicking of the “Take Photo” button):
CGImageRef img = UIGetScreenImage(); UIImage *grabbedImage = [UIImage imageWithCGImage:img]; // you can now manipulate the grabbedImage; CFRelease(img);
Update 2009-01-17: for some reason the overlay reappears when the view is redrawn, and it doesn’t seem that viewDidAppear gets recalled. Peeking at lajos’ code, he uses the method setHidden:YES, and it works for what I did too. So I’ve “commented out” my previous code that deletes the overlay and replaced it with one that just makes the overlay – as the method tells you – hidden.
Hey,
I found your site through erica’s blog. Any chance I could take a look at the source code to get this example working?
Thanks,
Lar
Hello netsharc,
I have a small xcode project and write up to demonstrate some tweaks to the camera interface here: custom UIImagePickerController camera view.
I used your suggestion to override the viewDidLoad method. I’ve noted that on my post.
Thanks!