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!!!
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
-----
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?
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!
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.
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?
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
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
-----
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!
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
-----
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!
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!!!!
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
-----