Accessing the camera from the app itself - iphone

I am trying out a simple camera app for practice. Was following these examples: iOS 6 App
and iOS 4 App
My code looks like this:
ViewController.h
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController<UINavigationControllerDelegate, UIImagePickerControllerDelegate>
{
UIButton *button;
UIImageView *imageView;
}
#property (nonatomic, retain) IBOutlet UIImageView *imageView;
- (IBAction)useCamera;
- (IBAction)useCameraRoll;
#end
ViewController.m
#import "ViewController.h"
#import <MobileCoreServices/MobileCoreServices.h>
#interface ViewController ()
#end
#implementation ViewController
#synthesize imageView;
- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex
{
// After saving iamge, dismiss camera
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
UIAlertView *alert;
// Unable to save the image
if (error)
alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"Unable to save image to Photo Album."
delegate:self cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
else // All is well
alert = [[UIAlertView alloc] initWithTitle:#"Success"
message:#"Image saved to Photo Album."
delegate:self cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Access the uncropped image from info dictionary
UIImage *image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
// Save image
UIImageWriteToSavedPhotosAlbum(image, self, #selector(image:didFinishSavingWithError:contextInfo:), nil);
}
- (id)init
{
if (self = [super init])
{
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view.backgroundColor = [UIColor grayColor];
// Button to activate camera
button = [[UIButton alloc] initWithFrame:CGRectMake(80, 55, 162, 53)];
[button setBackgroundImage:[UIImage imageNamed:#"Camera.png"] forState:UIControlStateNormal];
[button addTarget:self action:#selector(buttonPressed:) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)useCamera
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
- (IBAction)useCameraRoll
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
#end
My problem I like to access the camera from the app itself. What happens is that when i click useCamera button, it opens up the camera and take the image. Is it possible it could do that from the app itself? Sorry if it is a stupid question. Do point me out if I am doing something wrong.

Yes, use the UIImagePickerController class.
When the camera button is clicked, present an instance of UIImagePickerController. Also, since some iOS devices like the original iPad or some older iPod touches don't have cameras, I wouldn't recommend using separate buttons/methods for taking a new picture vs using one from the saved photos. Use one button and set its source type based on the device's capabilities using the available methods in the class. It may require rethinking your app's design, but it's also more likely to pass Apple's UI inspection, as they may not approve an app that has a button exclusively for taking a picture but can run on a device without a camera.
Once the user has either taken a new photo or chosen a photo from either the camera roll, use the imagePickerController:didFinishPickingMediaWithInfo: method from the UIImagePickerControllerDelegate class to pass the user's choice to your code.
Instances of UIImagePickerController are designed to be presented modally on all iOS devices when using the camera. Remember, as the name suggests, they are controllers and NOT views, so they shouldn't be used as subviews of UIView. While it may be possible to get creative with how you present it, you'll almost certainly have some side-effects and you'll further increase the chance that Apple will reject it. It only SEEMS like it's getting out the app to take the photo, but because you're presenting the controller from your app, it's still very much a part of it. Apple doesn't allow direct access to the camera hardware, which is exactly why they've created this class.

Related

Camera app displaying white screen

Im newish to Objective-C and I want to create an app with that will eventually take pictures with the camera but with images overlaid. But I thought I would start with a simple camera app just to get the base for it. I have followed a tutorial for creating a app that you can take pictures with and access image library. BUT when I build it to my iPhone 4s it just loads a white screen. If any one could take a look at the code, but I think its right and offer an answer it would be great thanks.
//ViewController.h
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>
#property (strong, nonatomic) IBOutlet UIImageView *imageView;
- (IBAction)takePhoto:(UIButton *)sender;
- (IBAction)selectPhoto:(UIButton *)sender;
#end
//ViewController.m
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"Device has no camera"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles: nil];
[myAlertView show];
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (IBAction)takePhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];
}
- (IBAction)selectPhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
}
#pragma mark - Image Picker Controller delegate methods
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissViewControllerAnimated:YES completion:NULL];
}
#end

Handle with 'UIImagePickerController' and 'allowsEditing' to get perfect square

How can I assure that UIImagePickerController always returns a squared image?
WhatsApp does it but I have not found a way to achieve this.
How it is in my App (Build in iOS 7)
How it should be (WhatsApp - iOS 6)
My code:
- (IBAction)showImagePicker:(id)sender {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
if ([sender tag] == 1) {
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else {
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentModalViewController:imagePicker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
_imageView.image = [info objectForKey:UIImagePickerControllerEditedImage];
[self dismissModalViewControllerAnimated:YES];
}
well to change the size of the image captured you need to set the mode for view in your UIImageView in IB to scale to fill. then when the image is chosen from library or from camera, it automaticaly will be resized. you do have to turn the autolayout off though since it wont allow the ImageView to be resized. you code is fine. anyhow here is sample app codes you can build to understand it a bit better.
.h
#import <UIKit/UIKit.h>
#interface ImageTestViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
#property (strong, nonatomic) IBOutlet UIImageView *imageView;
- (IBAction)takePhoto: (UIButton *)sender;
- (IBAction)selectPhoto:(UIButton *)sender;
#end
.m
#import "ImageTestController.h"
#interface ImageTestViewController ()
#end
#implementation ImageTestViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"Device has no camera"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles: nil];
[myAlertView show];
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (IBAction)takePhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];
}
- (IBAction)selectPhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissViewControllerAnimated:YES completion:NULL];
}
#end
in the ImageTestController Xib or view in storyboard, place two buttons, one for each action and create the necessary links in IB. then place a UIImageView to fill whatever size you want in the view. click the UIImageView and in view section of attribute inspector change the mode to scale to fill. turn the autolayout off. try adding an image to your simulator just to test it. make sure the image is of the landscape size. build and run and when you select the image from image library, it will automatically resize to square or any other size you set your UIImageView.
i know you are aware of most of the steps above, but i wrote this answer not to just help you get rid of your issue but for others that may have similar issues. hope it helps you out man.

IOS UIImagePicker in a UIView subview

I am trying to display a UIImagePicker from a programatically generated UIView that's added as a subview of the original view controller. The image picker comes up and so does the camera but the functionality breaks and nothing navigates properly. How do I properly load an image picker from a UIView and not a UIControlView?
code that breaks:
- (void)captureImage:(id)sender
{
[[[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:#"Close"
destructiveButtonTitle:nil
otherButtonTitles:#"Take photo", #"Camera Roll", nil]
showInView:self];
}
//UIImagePicker specific methods
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex)
{
case 0:
[self takePhoto];
break;
case 1:
[self fromCameraRoll];
break;
}
}
-(void)takePhoto
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == YES)
{
// Create image picker controller
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
// Set source to the camera
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Delegate is self
imagePicker.delegate = self;
// Show image picker
[self addSubview:imagePicker.view];
}
}
-(void)fromCameraRoll
{
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self addSubview:imgPicker.view];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Access the uncropped image from info dictionary
UIImage *image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
//do something with the image
//add code to pick images here and store them in the preview
[picker dismissModalViewControllerAnimated:NO];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissModalViewControllerAnimated:NO];
}
UIImagePickerController is view controller class, you better present your image picker to your parent view controller by a delegate call or something like with an overlay subview to achieve your goal.
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
CustomOverlayView *overlayview = [[CustomOverlayView alloc] init];
imgPicker.cameraOverlayView = overlayview;
[self presentModelViewController:imgPicker animated:YES];
add another delegate in your overlay class to dismiss your camera picker controller view
[imgPicker dismissModelViewControllerAnimated:YES];

UIButton Image not changing/updating

First off I am still new to objective-c and still trying to learn as much as I can so please bear with me.
Right now I have a UIButton that I've created programmatically. When the button is pressed an UIActionSheet is brought up with the choice of "Camera," "Choose Photo" or "Cancel." The button image is then suppose to change to the image taken (if camera was chosen) or image picked (if the camera roll was chosen).
My problem is the button's image is not changing after UIImagePicker is dismissed. At first the button was created as a subView of a tableView and when I scrolled the tableView, it refreshed the button and the image changed (this is not how I wanted it to behave of course). However if the user decides they want to change or remove the image, they just push the button again and the UIActionSheet displays a third choice to "Remove Photo." After scrolling the tableView I realized the button image was not changing at all, but instead a new button was created on top of the old button so I move the UIButton code to viewDidLoad instead (based upon some information found here on stackoverflow). I have also removed the ability for the tableView to scroll as I did not need scrolling for it.
I've been trying to solve this problem for a few days now how to refresh either the button, or the view properly after either UIImagePicker is dismissed or UIActionSheet is dismissed. I have tried using setNeedsLayout and setNeedsDisplay but these have not worked to fix my problem (I might be putting these in the wrong place). Hopefully someone has insight on this and can guide me on the proper way to make this work. Also provided is my code:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
// Creates camera button and connects to camera menu UIActionSheet
UIButton *cameraButton = [UIButton buttonWithType:UIButtonTypeCustom];
[cameraButton addTarget:self action:#selector(showActionSheet:) forControlEvents:UIControlEventTouchUpInside];
cameraButton.titleLabel.lineBreakMode = UILineBreakModeWordWrap;
cameraButton.titleLabel.textAlignment = UITextAlignmentCenter;
cameraButton.frame = CGRectMake(9, 230, 80, 80);
[self.view addSubview:cameraButton];
picturePresent = NO;
NSLog(#"picturePresent = %#", picturePresent);
}
-(void)showActionSheet:(id)sender {
if (picturePresent == NO) {
UIActionSheet *cameraMenuSheet = [[UIActionSheet alloc] initWithTitle:#"Add Photo"
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:#"Camera", #"Choose Photo", nil];
[cameraMenuSheet showFromTabBar:self.tabBarController.tabBar];
}
else if (picturePresent == YES) {
UIActionSheet *cameraMenuSheet = [[UIActionSheet alloc] initWithTitle:#"Add Photo"
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:#"Remove Photo", #"Camera", #"Choose Photo", nil];
[cameraMenuSheet showFromTabBar:self.tabBarController.tabBar];
}
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *title = [actionSheet buttonTitleAtIndex:buttonIndex];
// Initialize UIImagePickerController
if ([title isEqualToString:#"Camera"]) {
// Camera
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.allowsEditing = NO;
imagePicker.showsCameraControls = YES;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];
[self presentModalViewController:imagePicker animated:YES];
newMedia = YES;
}
else if ([title isEqualToString:#"Choose Photo"]) {
// Photo library
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
imagePicker.delegate = self;
imagePicker.allowsEditing = NO;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];
[self presentModalViewController:imagePicker animated:YES];
newMedia = NO;
}
else if ([title isEqualToString:#"Remove Photo"]) {
picturePresent = NO;
}
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
[self.view setNeedsDisplay];
}
// Method for saving image to photo album
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
// Access the uncropped image from info dictionary
UIImage *image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
UIImage *scaledImage = [image scaleToSize:CGSizeMake(80.0, 80.0)];
if (newMedia == YES) {
// Save image
UIImageWriteToSavedPhotosAlbum(image, self, #selector(image:didFinishSavingWithError:contextInfo:), nil);
}
resizedImage = scaledImage;
}
picturePresent = YES;
[self dismissModalViewControllerAnimated:NO];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissModalViewControllerAnimated:YES];
}
Additionally, now that I have moved my UIButton coding to viewDidLoad I am unsure of where to put this piece of coding:
{
if (picturePresent == NO) {
[cameraButton setTitle:#"Add\nPhoto" forState:UIControlStateNormal];
}
else if (picturePresent == YES) {
[cameraButton setImage:resizedImage forState:UIControlStateNormal];
}
}
Also setImage and setBackgroundImage were both used and still not working how I want it to. Let me know if more information is needed, thanks!
EDIT:
Here are some screenshots to show what I am aiming for -
"Picture" is suppose to represent a picture that was taken or selected and then scaled to fit the button size.
Did not test it, but if you make your cameraButton member of your UiViewController so that you can access whenever needed, you could call the setImage: forState: right after caculating the resizedImage - no picturePresent bool needed. And I think setNeedsDisplay Not needed as well.
EDIT:
In your view controller header file do something like
...
#interface MyViewController : UIViewController
{
...
UIButton * cameraButton;
...
}
...
Somewhere in your implementation file (viewDidiLoad is Ok) do:
...
cameraButton = [UIButton buttonWithType:UIButtonTypeCustom];
...
[self.view addSubview:cameraButton];
...
And then implement all the other stuff you did and change the code in didFinishPickingMediaWithInfo like this:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
...
[cameraButton scaledImage forState:UIControlStateNormal];
}
As I said, didn't test it, but I think it should work.
Move the viewDidLoad code to the end of imagePickerController:didFinishPickingMediaWithInfo:. Also if you can post a few screenshots it will help explain exactly what is going on, as well as what you expect. This could be a cropping issue, which is why I suggest posting screenshots.
long time i've searched for answers..now here some:
to change image of a button the code below helped me:
[button.imageView setHighlighted:YES];
[button.imageView setHighlightedImage:[UIImage imageNamed:#"mypic.png"]];
[button.imageView setImage:[UIImage imageNamed:#"mypic.png"]];
..e.g. in viewDidLoad.
hope that helps...

access camera from uiwebview?

Is it possible to access iphone's camera from uiwebview? I know phonegap does it, but how to make it work without phonegap?
Thanks.
You can implement the UIWebView Delegate and intercept any attempted page load. By setting a custom url, you can pass a message to Objective C, that can launch the camera. To send data back to the web weiw you can initiate a new load (as I do in my example), or pass in some javascript using another method on UIWebView.
Here is a working example, I just wrote:
#import "WebViewCamAppDelegate.h"
#import <UIKit/UIKit.h>
#interface uiwebviewcameraAppDelegate : NSObject <UIApplicationDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIWebViewDelegate> {
UIWindow *window;
UIViewController *viewController;
UIWebView *webView;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#end
#implementation uiwebviewcameraAppDelegate
#synthesize window;
//This is the HTML we initially show in the WebView. Note the url "showcamera:" is one I
//invented with the intent to intercept it to show the camera.
static NSString *htmlString = #"<br>Show Camera";
//Pretty Basic stuff. We set the UIWebView Delegate so we can intercept the call and set up //a ViewController so we can animate the UIImagePicker
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
viewController = [[UIViewController alloc] init];
webView = [[UIWebView alloc] initWithFrame:window.bounds];
[webView loadHTMLString:htmlString baseURL:nil];
webView.delegate = self;
[viewController.view addSubview:webView];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
//Note: I check to make sure the camera is available. If it is not (iPod touch or Simulator) I show the photo library instead.
-(void) showCamera {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else {
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
imagePicker.delegate = self;
[viewController presentModalViewController:imagePicker animated:YES];
}
//Here we intercept any time the webview tries to load a document. When the user hits our "showcamera: url" we go to work.
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if ([[[request URL] scheme] isEqualToString:#"showcamera"]) {
[self showCamera];
return NO;
}
return YES;
}
//After the imagepicker has done it's thing, we pass the data back to the webview to be displayed.
//If we wanted to be fancy here, we could have done this via Javascript so we could dynamically insert an image without reloading the page.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[viewController dismissModalViewControllerAnimated:YES];
UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage];
NSData *imageData = UIImageJPEGRepresentation (image, 0.5);
[webView loadData:imageData MIMEType:#"image/jpeg" textEncodingName:#"UTF-8" baseURL:nil];
}
- (void)dealloc {
[viewController release];
[webView release];
[window release];
[super dealloc];
}
#end