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 11-21-2011, 05:56 AM   #1 (permalink)
Registered Member
 
Join Date: Nov 2011
Posts: 5
chrisb_1988 is on a distinguished road
Default How to pass imageView over segue in storyboards

Ok, so I'm relatively new to xcode and have hit a dead end on this particular topic. I'm not too sure what code I need.

I am currently trying to force a segue (using storyboards) from one View Controller to another View Controller. Once the user has selected an image using UIImagePickerController the picker dismisses itself leaving the selected image in the ImageView.

However once the picker dismisses itself I then want to perform a segue that recognizes that this has occurred and then sends the image in the ImageView to the new View Controller.

Heres my code so far (Ive annotated the bits I'm stuck on)

Code:
@implementation SantaViewController
@synthesize imageView,choosePhotoBtn, takePhotoBtn;

- (void)viewDidLoad {
    if (![UIImagePickerController isSourceTypeAvailable:
          UIImagePickerControllerSourceTypeCamera]) {
        takePhotoBtn.hidden = YES;
    }
}

-(IBAction) getPhoto:(id) sender {
	UIImagePickerController * picker = [[UIImagePickerController alloc] init];
	picker.delegate = self;
    
	if((UIButton *) sender == choosePhotoBtn) {
		picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
	} else {
		picker.sourceType = UIImagePickerControllerSourceTypeCamera;
	}
    
	[self presentModalViewController:picker animated:YES];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
	[picker dismissModalViewControllerAnimated:YES];
    imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

}
    
    //  This is where i need to place the identifier.
    //  The Identifier needs to be the picker dismissing itself and leaving an image in ImageView. 
{
    [self performSegueWithIdentifier:@"homeEdit" sender:sender];
}

   - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

        if ([segue.identifier isEqualToString:@"homeEdit"])
    
{
    SantaViewController2 *viewController = segue.destinationViewController;
    
    [viewController //pass imageView to the destination View Controller code. ];
     
}
Any help would be greatly appreciated guys and sorry if its an easy answer that I've missed.
chrisb_1988 is offline   Reply With Quote
Old 12-03-2011, 06:54 PM   #2 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 1
digimatt22 is on a distinguished road
Default update?

Did you ever solve this problem? I am facing a similar issue and any help would be appreciated.

THANKS!
digimatt22 is offline   Reply With Quote
Old 12-03-2011, 07:12 PM   #3 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by digimatt22 View Post
Did you ever solve this problem? I am facing a similar issue and any help would be appreciated.

THANKS!
You should watch the 2011 WWDC video session on Storyboard. They explain this specifically.

There is also info in the documentation on storyboards that tells you what to do:


Quote:
Preparing to Transition to a New View Controller
Whenever a user triggers a segue in the current scene, the storyboard runtime calls the prepareForSegue:sender: method of the current view controller. This method gives the current view controller an opportunity to pass any needed data to the view controller that is about to be displayed. When implementing your view controller classes, you should override this method and use it to handle these transitions.
The key bit is in bold. You need to use the method prepareForSegue:sender:
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 05-16-2012, 09:41 AM   #4 (permalink)
New User
 
Join Date: Aug 2011
Posts: 8
Rynow is on a distinguished road
Default Same issue

I am stuck trying to figure out the same scenario.
I read in one place that the UIImagePicker is not available in storyboards and had to be brought in via core data...helper class.

I would love to know how to make this work without all that.
I just want to do what chrisb was trying.

Within a view controller goto photo library, pick an image and have it stay in an image view on that view controller window.

I am using Xcode 4.2

Anyone who could explain this?
R
Rynow is offline   Reply With Quote
Old 05-16-2012, 07:56 PM   #5 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by Rynow View Post
I am stuck trying to figure out the same scenario.
I read in one place that the UIImagePicker is not available in storyboards and had to be brought in via core data...helper class.

I would love to know how to make this work without all that.
I just want to do what chrisb was trying.

Within a view controller goto photo library, pick an image and have it stay in an image view on that view controller window.

I am using Xcode 4.2

Anyone who could explain this?
R
I've never tried to save an image picker in a nibfile or a storyboard. I don't think it's available in either
When I need one, I just create one and invoke it in code. It's only a couple of lines of code.

Loading an image picker from Core Data makes no sense whatsoever. Core data is for saving app data, not view objects. You've got your information mixed up.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 05-16-2012, 08:13 PM   #6 (permalink)
New User
 
Join Date: Aug 2011
Posts: 8
Rynow is on a distinguished road
Default

the helper class I was speaking of was from a tutorial i tried to complete quite sometime ago....so my memory is kinda foggy as to the approach.

http://maybelost.com/2011/12/tutoria...ith-core-data/

but it boils down to the fact that it's not available in storyboards.

What I am trying to to is create a deep tableview ap in storyboards, where at the bottom level there is a model view that has details like ingredients, notes, and the means to take a photo or select photo from the photo library and have it assigned to an image view on that view and as a cell detail image. I have all of it done accept for this missing functionality.

I'd be grateful to know what the few lines of code are to solve (getting the camera functions image picker fuinction in my layout ) this and not have to keep messing around with augmenting tutorials I find everywhere.


please enlighten me.

Last edited by Rynow; 05-16-2012 at 10:45 PM. Reason: Added details
Rynow is offline   Reply With Quote
Old 05-17-2012, 05:06 AM   #7 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by cavisboung View Post
I am facing a similar issue and any help would be appreciated.
So restate the problem to prove that you are not a bot.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 05-17-2012, 05:07 AM   #8 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by Alice246 View Post
Did you ever solve this problem? I am facing a similar issue and any help would be appreciated.
Are you a bot?
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 05-17-2012, 04:17 PM   #9 (permalink)
New User
 
Join Date: Aug 2011
Posts: 8
Rynow is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
Are you a bot?
No I'm not a bot?
Are you?

Bots don't write questions then come back and edit them....least I don't think so.

Now that I'm not a bot....can you enlighten me?

R
Rynow is offline   Reply With Quote
Old 05-18-2012, 09:22 AM   #10 (permalink)
New User
 
Join Date: Feb 2012
Posts: 2
ZomZom is on a distinguished road
Default

Once you've segued, you can reference the calling view controller by navigating your encompassing view controllers. For example, if your view controllers are embedded in a UINavigationController, you could do this in your destination view controller's viewWillAppear:

Code:
UINavigationController *nav = self.navigationController;
SantaViewController    *svc = [nav.viewControllers objectAtIndex:0];
Assuming that the calling view controller was the first in the navigation stack. You could then reference svc.imageView to get the calling imageView. (Note that I'm not at my Mac and haven't syntax-checked this code.)
ZomZom is offline   Reply With Quote
Old 05-18-2012, 03:53 PM   #11 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by Rynow View Post
No I'm not a bot?
Are you?

Bots don't write questions then come back and edit them....least I don't think so.

Now that I'm not a bot....can you enlighten me?

R
Not you. There were 2 other posters (almost certainly bots) who posted in the thread.

You should start a new thread, since you are asking a new question.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Reply

Bookmarks

Tags
imageview, segue, 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: 388
14 members and 374 guests
7twenty7, chiataytuday, Clouds, dedeys78, Duncan C, e2applets, EvilElf, iekei, ipodphone, jeroenkeij, leostc, mbadegree, Murphy, QuantumDoja
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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