Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Display Image taken from camera

TiggyLiTiggyLi Posts: 11Registered Users
Hi,

In my app that I'm developing, I can access the camera and photo library and display the image chosen on the same page, I want to display the image on a different page (or view). I don't know how to do it, I hope someone can help me... :confused:

Thanks
Tigris
Post edited by TiggyLi on

Replies

  • baja_yubaja_yu Posts: 6,166Super Moderators, Registered Users
    Pass the image to the other view's controller, just like you would any other object.
  • TiggyLiTiggyLi Posts: 11Registered Users
    baja_yu;414839 said:
    Pass the image to the other view's controller, just like you would any other object.
    I tried to do that at first but when I have chosen a picture or taken one, it stays on the same page and it won't go to the second view.

    any other suggestions..?
  • baja_yubaja_yu Posts: 6,166Super Moderators, Registered Users
    How can I tell you what's wrong with your code if I don't see it?
  • TiggyLiTiggyLi Posts: 11Registered Users
    baja_yu;414879 said:
    How can I tell you what's wrong with your code if I don't see it?
    Here's the code, this is the viewcontroller.m


    #pragma mark - View lifecycle

    - (void)viewDidLoad {
    if (![UIImagePickerController isSourceTypeAvailable:
    UIImagePickerControllerSourceTypeCamera]) {
    takePictureButton.hidden = YES;
    }
    }
    #pragma mark -
    // Camera
    -(IBAction)getCameraPicture:(id)sender {
    UIImagePickerController *picker =
    [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsImageEditing = NO;
    picker.sourceType = (sender == takePictureButton) ?
    UIImagePickerControllerSourceTypeCamera :
    UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    [self presentModalViewController:picker animated:YES];
    [picker release];

    }
    // Photo Library
    -(IBAction)selectExistingPicture {
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
    UIImagePickerController *picker =
    [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsImageEditing = NO;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentModalViewController:picker animated:YES];
    [picker release];
    }
    else {
    UIAlertView *alert = [[UIAlertView alloc]
    initWithTitle:@\"Error acessing Photo Library\"
    message:@\"Deice does not support a Photo Library\"
    delegate:nil
    cancelButtonTitle:@\"Dismiss\"
    otherButtonTitles:nil];
    [alert show];
    [alert release];
    }
    }
    #pragma mark -
    -(void)imagePickerController:(UIImagePickerController *)picker
    didFinishPickingImage:(UIImage *)image
    editingInfo:(NSDictionary *)editingInfo {
    imageView.image = image;
    [picker dismissModalViewControllerAnimated:YES];

    }
    -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

    [picker dismissModalViewControllerAnimated:YES];
    }


    This one is in the viewcontroller.h


    @interface ViewController : UIViewController <UIImagePickerControllerDelegate> {

    UIButton *takePictureButton;
    UIImageView *imageView;

    }

    @property (nonatomic, retain) IBOutlet UIImageView *imageView;

    -(IBAction)getCameraPicture:(id)sender;
    -(IBAction)selectExistingPicture;


    I hope you can help me, thanks! :)
Sign In or Register to comment.