Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-23-2011, 02:58 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 210
lukeirvin is on a distinguished road
Default 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!
lukeirvin is offline   Reply With Quote
Old 08-23-2011, 03:13 PM   #2 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

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.
Domele is offline   Reply With Quote
Old 08-25-2011, 01:43 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 210
lukeirvin is on a distinguished road
Default

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
lukeirvin is offline   Reply With Quote
Old 08-25-2011, 02:58 PM   #4 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

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.
Domele is offline   Reply With Quote
Old 08-25-2011, 04:26 PM   #5 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 210
lukeirvin is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
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.
lukeirvin is offline   Reply With Quote
Old 08-25-2011, 04:27 PM   #6 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

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.
Domele is offline   Reply With Quote
Old 08-25-2011, 04:34 PM   #7 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 210
lukeirvin is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
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.
lukeirvin is offline   Reply With Quote
Old 08-25-2011, 04:42 PM   #8 (permalink)
Rko
Registered Member
 
Join Date: Jun 2010
Posts: 63
Rko is on a distinguished road
Default

Quote:
Originally Posted by lukeirvin View Post
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...!!!!
Rko is offline   Reply With Quote
Old 08-25-2011, 04:49 PM   #9 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 210
lukeirvin is on a distinguished road
Default

Quote:
Originally Posted by Rko View Post
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.
lukeirvin is offline   Reply With Quote
Old 08-25-2011, 05:05 PM   #10 (permalink)
Rko
Registered Member
 
Join Date: Jun 2010
Posts: 63
Rko is on a distinguished road
Default

Quote:
Originally Posted by lukeirvin View Post
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
Rko is offline   Reply With Quote
Old 08-25-2011, 05:07 PM   #11 (permalink)
Rko
Registered Member
 
Join Date: Jun 2010
Posts: 63
Rko is on a distinguished road
Default

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"
Rko is offline   Reply With Quote
Old 08-26-2011, 09:30 AM   #12 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 210
lukeirvin is on a distinguished road
Default

Quote:
Originally Posted by Rko View Post
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];
lukeirvin is offline   Reply With Quote
Old 08-26-2011, 01:32 PM   #13 (permalink)
Rko
Registered Member
 
Join Date: Jun 2010
Posts: 63
Rko is on a distinguished road
Default

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
Rko is offline   Reply With Quote
Old 08-26-2011, 02:20 PM   #14 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 210
lukeirvin is on a distinguished road
Default

Changed those two things. Still doesn't work
lukeirvin is offline   Reply With Quote
Reply

Bookmarks

Tags
camera, image, send, uiview, uiviewcontroller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:13 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0