08-23-2011, 02:58 PM
#1 (permalink )
Registered Member
Join Date: Jun 2010
Posts: 210
How to caputure an image and send it to a UIViewController or UIView
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!
08-23-2011, 03:13 PM
#2 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
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 thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
08-25-2011, 01:43 PM
#3 (permalink )
Registered Member
Join Date: Jun 2010
Posts: 210
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
08-25-2011, 02:58 PM
#4 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
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 thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
08-25-2011, 04:26 PM
#5 (permalink )
Registered Member
Join Date: Jun 2010
Posts: 210
Quote:
Originally Posted by
Domele
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.
08-25-2011, 04:27 PM
#6 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
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 thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
08-25-2011, 04:34 PM
#7 (permalink )
Registered Member
Join Date: Jun 2010
Posts: 210
Quote:
Originally Posted by
Domele
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.
08-25-2011, 04:42 PM
#8 (permalink )
Registered Member
Join Date: Jun 2010
Posts: 63
Quote:
Originally Posted by
lukeirvin
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...!!!!
08-25-2011, 04:49 PM
#9 (permalink )
Registered Member
Join Date: Jun 2010
Posts: 210
Quote:
Originally Posted by
Rko
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.
08-25-2011, 05:05 PM
#10 (permalink )
Registered Member
Join Date: Jun 2010
Posts: 63
Quote:
Originally Posted by
lukeirvin
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
08-25-2011, 05:07 PM
#11 (permalink )
Registered Member
Join Date: Jun 2010
Posts: 63
BTW,
Code:
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"
08-26-2011, 09:30 AM
#12 (permalink )
Registered Member
Join Date: Jun 2010
Posts: 210
Quote:
Originally Posted by
Rko
BTW,
Code:
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.bound s.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];
08-26-2011, 01:32 PM
#13 (permalink )
Registered Member
Join Date: Jun 2010
Posts: 63
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
08-26-2011, 02:20 PM
#14 (permalink )
Registered Member
Join Date: Jun 2010
Posts: 210
Changed those two things. Still doesn't work
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 397
15 members and 382 guests
7twenty7 , chiataytuday , cristofercolmbos , dedeys78 , fiftysixty , gmarro , iOS.Lover , jonathandeknudt , kilobytedump , Matrix23 , raymng , stanny , tymex , UMAD , xerohuang
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78