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-31-2011, 10:59 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 42
xcoderx is on a distinguished road
Default Change UIImageView image to another?

Hey guys, im very new to the forum. But i decided id ask you all super smart coders out there a simple question. I have 2 pages. ON the first page i simply have 1 button. The second page has a BLANK/EMPTY UIImageView. When the button is pressed, i want an image to be on the second view when that view comes up. Could anybody please help me with this? Thanks a lot!!!
xcoderx is offline   Reply With Quote
Old 08-31-2011, 11:55 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 241
MattW is on a distinguished road
Default

Quote:
Originally Posted by xcoderx View Post
Hey guys, im very new to the forum. But i decided id ask you all super smart coders out there a simple question. I have 2 pages. ON the first page i simply have 1 button. The second page has a BLANK/EMPTY UIImageView. When the button is pressed, i want an image to be on the second view when that view comes up. Could anybody please help me with this? Thanks a lot!!!
Where is the image that appears on the second view? Is it in your bundle? Is it a local file? Is it off the web?
__________________

Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----


FourSixteen Productions
MattW is offline   Reply With Quote
Old 09-01-2011, 02:54 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2011
Location: Texas
Posts: 20
daltonclaybrook is on a distinguished road
Default

Quote:
Originally Posted by xcoderx View Post
Hey guys, im very new to the forum. But i decided id ask you all super smart coders out there a simple question. I have 2 pages. ON the first page i simply have 1 button. The second page has a BLANK/EMPTY UIImageView. When the button is pressed, i want an image to be on the second view when that view comes up. Could anybody please help me with this? Thanks a lot!!!
In addition to MattW's question, what do you mean by "page"? Do you mean two pages in a UITabBar, or in a UIScrollView, or do you mean something else?
daltonclaybrook is offline   Reply With Quote
Old 09-05-2011, 01:11 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 42
xcoderx is on a distinguished road
Default

Quote:
Originally Posted by daltonclaybrook View Post
In addition to MattW's question, what do you mean by "page"? Do you mean two pages in a UITabBar, or in a UIScrollView, or do you mean something else?
I mean like two different view controllers and i switch between them with a button. And im not sure how to answer MattW's question i just threw an Image View onto my .xib file. Thanks for the help btw!
xcoderx is offline   Reply With Quote
Old 09-05-2011, 01:15 PM   #5 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 42
xcoderx is on a distinguished road
Default

Quote:
Originally Posted by MattW View Post
Where is the image that appears on the second view? Is it in your bundle? Is it a local file? Is it off the web?
you know... im a noob at programming so ill just say that i dragged and dropped my UIImageView onto the .xib file.
xcoderx is offline   Reply With Quote
Old 09-05-2011, 01:46 PM   #6 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

He means, where are you getting the images from?

1. You dragged and dropped a image into your project
2. You are downloading it off the internet
3. You are getting it from a local source (not likely)

Which number?
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 09-05-2011, 03:31 PM   #7 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 42
xcoderx is on a distinguished road
Default

Quote:
Originally Posted by Objective Zero View Post
He means, where are you getting the images from?

1. You dragged and dropped a image into your project
2. You are downloading it off the internet
3. You are getting it from a local source (not likely)

Which number?
Oh i understand. I did Number 1!! Thanks for the clarification!
xcoderx is offline   Reply With Quote
Old 09-05-2011, 04:18 PM   #8 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 16
Aibo is on a distinguished road
Default

Have a global boolean variable that keeps track whether the button was pressed. If it was, set it to YES.

In the 2nd view controller implementation file check the value of this variable, and display the image if it is YES.
__________________
Natus: Sharing App - Contact me for Promo Codes.
Aibo is offline   Reply With Quote
Old 09-05-2011, 04:23 PM   #9 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

No global variables are bad. Create a BOOL property in the 2nd view controller and name it something like displayImage. In your view will appear method, check the BOOL and act accordingly. Now when you go to push your 2nd view controller, set that property.
__________________
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 09-06-2011, 10:47 PM   #10 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 42
xcoderx is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
No global variables are bad. Create a BOOL property in the 2nd view controller and name it something like displayImage. In your view will appear method, check the BOOL and act accordingly. Now when you go to push your 2nd view controller, set that property.
ok, i have tried this BOOL method and many others to try to get this to work, but it wont? IS there another way to do it?
xcoderx is offline   Reply With Quote
Old 09-06-2011, 10:49 PM   #11 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Post code, it has to work.
__________________
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 09-06-2011, 10:53 PM   #12 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 42
xcoderx is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
No global variables are bad. Create a BOOL property in the 2nd view controller and name it something like displayImage. In your view will appear method, check the BOOL and act accordingly. Now when you go to push your 2nd view controller, set that property.
ok, here is my code:

THis is for the button that i want to set the image in the second controller:

- (IBAction)outlet1 {
cart.displayImage = YES;
}


This is the viewDidLoad for the second viewController


- (void)viewDidLoad; {
[super viewDidLoad];
if (displayImage == YES) {
imageView.image = [UIImage imageNamed:@"paddle1.png"];
}
}

I set and check the bool then set the image but i dont know why it wont work? Thanks

Last edited by xcoderx; 09-06-2011 at 10:56 PM.
xcoderx is offline   Reply With Quote
Old 09-06-2011, 11:20 PM   #13 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 241
MattW is on a distinguished road
Default

Here's the flow:

1) User hits button
2) VC1 creates VC2, and sets the BOOL value in VC2
3) VC1 excuses itself, and adds VC2 to the subview or pushes it.
4) VC2, in its viewWillAppear() checks the state of its BOOL and does the appropriate thing with the image.

And that's it.

Things to note:

1) The BOOL needs to be in the VC that will display the image (VC2)
2) The button press IBAction function will be in VC1.
3) You have to create VC2 before you can set the BOOL variable.
__________________

Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----


FourSixteen Productions
MattW is offline   Reply With Quote
Old 09-06-2011, 11:28 PM   #14 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 42
xcoderx is on a distinguished road
Default

Quote:
Originally Posted by MattW View Post
Here's the flow:

1) User hits button
2) VC1 creates VC2, and sets the BOOL value in VC2
3) VC1 excuses itself, and adds VC2 to the subview or pushes it.
4) VC2, in its viewWillAppear() checks the state of its BOOL and does the appropriate thing with the image.

And that's it.

Things to note:

1) The BOOL needs to be in the VC that will display the image (VC2)
2) The button press IBAction function will be in VC1.
3) You have to create VC2 before you can set the BOOL variable.

Ok i think i got it, but what do you mean by create VC2 before i set the variable? P.S. i checked out your apps on the store and they are some pretty sweet looking apps, and i bought the highlighter one!! Thanks again!
xcoderx is offline   Reply With Quote
Old 09-07-2011, 12:51 AM   #15 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 241
MattW is on a distinguished road
Default

Quote:
Originally Posted by xcoderx View Post
Ok i think i got it, but what do you mean by create VC2 before i set the variable? P.S. i checked out your apps on the store and they are some pretty sweet looking apps, and i bought the highlighter one!! Thanks again!
LOL. Flattery will get you everywhere.

You need to create (alloc and init) an instance of VC2 (view controller 2.... whatever you've called it) as you would before you add it to the sub view or push it, otherwise there won't be memory allocated to store its data (basically, it won't exist).
__________________

Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----


FourSixteen Productions
MattW is offline   Reply With Quote
Old 09-07-2011, 08:24 PM   #16 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 42
xcoderx is on a distinguished road
Default

Quote:
Originally Posted by MattW View Post
LOL. Flattery will get you everywhere.

You need to create (alloc and init) an instance of VC2 (view controller 2.... whatever you've called it) as you would before you add it to the sub view or push it, otherwise there won't be memory allocated to store its data (basically, it won't exist).
lol
ok i got it!
I tried this code and it will not work? My nibs are good to go and the code seems flawless. Is there a reason the image isnt displaying? Could it be some thing to do with how i switch back and forth through the pages? Thanks again! Oh and MattW i have been coding for about 1 and a half years and im 16 years old and i was wondering is this a good career to get into? Do you make a lot or a pretty good amount of money? Thanks again!

Last edited by xcoderx; 09-07-2011 at 09:16 PM.
xcoderx is offline   Reply With Quote
Old 09-07-2011, 10:32 PM   #17 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 42
xcoderx is on a distinguished road
Default

Quote:
Originally Posted by MattW View Post
LOL. Flattery will get you everywhere.

You need to create (alloc and init) an instance of VC2 (view controller 2.... whatever you've called it) as you would before you add it to the sub view or push it, otherwise there won't be memory allocated to store its data (basically, it won't exist).
OH I GOT IT!!!! i was messing things up with my ivars. I just learned that i had to init the cart object in the init method!! THANKS FOR ALL THE HELP!!!!
xcoderx is offline   Reply With Quote
Old 09-07-2011, 10:41 PM   #18 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 241
MattW is on a distinguished road
Default

Good! Well done for figuring it out - that's the way to learn.
__________________

Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----


FourSixteen Productions
MattW is offline   Reply With Quote
Reply

Bookmarks

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: 396
5 members and 391 guests
JackReidy, jeroenkeij, Sami Gh, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,671
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, JackReidy
Powered by vBadvanced CMPS v3.1.0

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