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.

How to caputure an image and send it to a UIViewController or UIView

lukeirvinlukeirvin Posts: 269Registered Users
edited August 2011 in iPhone SDK Development
I am building a camera app. Currently my app can take photos and sends them to the native Photo Library.

I do know how to capture an image but how do I send that image to another view controller (or even a view)?

Should it use pushnavigationcontroller? or something else?

Thanks much!
Post edited by lukeirvin on

Replies

  • DomeleDomele Posts: 2,954Registered Users
    edited August 2011
    I assume you know how to get the UIImage object. Set up a view controller with an image property. Set that property with the UIImage object you get from the picture controller then present it using whatever method you want, pushing it via a nav controller or using the presentModalViewController method.
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
  • lukeirvinlukeirvin Posts: 269Registered Users
    edited August 2011
    I need some more help on this.

    Everything I have tried just hasn't worked.

    I'm obtaining this image but how do I read the image from the view controller I'm pushing too?

    I don't know how to connect these two view controllers together.

    Now, if I should just push to a different UIView from the same controller, how do I do that?

    What seems to be the better method here?

    Again, this is a camera app that would work like Instagram or Photovine
  • DomeleDomele Posts: 2,954Registered Users
    edited August 2011
    Setup a property on your next view controller. If you don't know what a property is, read Brian Slick's guide.
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
  • lukeirvinlukeirvin Posts: 269Registered Users
    edited August 2011
    Domele;368669 said:
    Setup a property on your next view controller. If you don't know what a property is, read Brian Slick's guide.
    As far as I know I have set up a property. Still don't know what to do beyond this.
  • DomeleDomele Posts: 2,954Registered Users
    edited August 2011
    Well alloc the next view controller, set its image property, and then present it however you want.
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
  • lukeirvinlukeirvin Posts: 269Registered Users
    edited August 2011
    Domele;368709 said:
    Well alloc the next view controller, set its image property, and then present it however you want.
    This is what I have so far:


    videoPreviewImageView = [[UIImageView alloc] init];
    [videoPreviewImageView setImage:self.img];
    [self.view addSubview:videoPreviewImageView];

    No clue if I'm on the right path or not.
  • RkoRko Posts: 63Registered Users
    edited August 2011
    lukeirvin;368714 said:
    This is what I have so far:


    videoPreviewImageView = [[UIImageView alloc] init];
    [videoPreviewImageView setImage:self.img];
    [self.view addSubview:videoPreviewImageView];

    No clue if I'm on the right path or not.

    NewViewController *aController = [[NewViewController alloc] init];
    aController.image = videoPreviewImageView.image;
    [self.navigationController pushViewController:aController animated:YES];

    NewViewController is a subclass of UIViewController and it has property for image.
    wen i mean property , somethin similar to the below code in .h:

    @property (nonatomic, retain) UIImage *image;

    Synthesis "image" in the .m class

    now u can use the image in the NewViewController by just using "self.image".


    Hope this helps...!!!!
  • lukeirvinlukeirvin Posts: 269Registered Users
    edited August 2011
    Rko;368718 said:
    NewViewController *aController = [[NewViewController alloc] init];
    aController.image = videoPreviewImageView.image;
    [self.navigationController pushViewController:aController animated:YES];

    NewViewController is a subclass of UIViewController and it has property for image.
    wen i mean property , somethin similar to the below code in .h:

    @property (nonatomic, retain) UIImage *image;

    Synthesis "image" in the .m class

    now u can use the image in the NewViewController by just using "self.image".


    Hope this helps...!!!!

    aController.image = videoPreviewImageView.image;

    There is issue with this line of code.

    I have image as a property and synthesized.
  • RkoRko Posts: 63Registered Users
    edited August 2011
    lukeirvin;368724 said:
    aController.image = videoPreviewImageView.image;

    There is issue with this line of code.

    I have image as a property and synthesized.
    probably u can try using self.img which u initially used to set to the imageview.
    It would b easy if u can paste ur code here...

    Cheers
    RKO
  • RkoRko Posts: 63Registered Users
    edited August 2011
    BTW,

     

    NewViewController *aController = [[NewViewController alloc] init];
    aController.image = self.img;
    [self.navigationController pushViewController:aController animated:YES];



    the above code comes in ur current view controller , after u've an image populated in "self.img"
  • lukeirvinlukeirvin Posts: 269Registered Users
    edited August 2011
    Rko;368732 said:
    BTW,

     

    NewViewController *aController = [[NewViewController alloc] init];
    aController.image = self.img;
    [self.navigationController pushViewController:aController animated:YES];



    the above code comes in ur current view controller , after u've an image populated in "self.img"
    Still not working. Here's what I've got going on.

    First View Controller:


    UIGraphicsBeginImageContext(videoPreviewView.bounds.size);
    [videoPreviewView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *videoPreviewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    NSData * imageData = UIImagePNGRepresentation(videoPreviewImage);
    NSString * filePath = @"photo.png";
    [imageData writeToFile:filePath atomically:YES];

    SetImageViewController * setImageViewController = [[SetImageViewController alloc] initWithNibName:@"SetImageViewController" bundle:nil];
    setImageViewController.image = self.image;
    [self.navigationController pushViewController:setImageViewController animated:YES];
    [setImageViewController release];

    [self dismissModalViewControllerAnimated:YES];


    Second View Controller:


    videoPreviewImageView = [[UIImageView alloc] init];
    [videoPreviewImageView setImage:self.image];
    [self.view addSubview:videoPreviewImageView];
  • RkoRko Posts: 63Registered Users
    edited August 2011
    Few quick doubts (Correct me if i m wrong) :
    UIImage *videoPreviewImage, this is populated with the image.
    then, why is
    setImageViewController.image = self.image;

    Shouldn't it be
    setImageViewController.image = videoPreviewImage;

    Also, immediately after the push , u are dismissing the current controller. I've my doubts on tat approach of urs as well.

    The rest looks fine :)
  • lukeirvinlukeirvin Posts: 269Registered Users
    edited August 2011
Sign In or Register to comment.