Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Right now I have multiple buttons set up, each are set to custom with an image.
Once the button is tapped I open a new ViewController to display the image.
I want to only use one ViewController/XIB for the images since it would be a headache to replicate this over and over and over again.
What would be the best method to implement this?
I think the difficult part is because I am using multiple buttons.
Should I set up one button and just scroll through my images and code it to know that when this image is on the button display it in the new XIB?
Or can I still set this up using the multiple buttons?
Any help is appreciated.
UIView objects have a property call tag. It's an integer.
Set up each button with a different, non-zero tag number.
Have each button invoke the same action.
In that action, check the tag number of the button, and use that to look up the image.
Add a UIImage property to your second view controller.
In the button action, look up the image using the tag number (from an array of images perhaps, or an array of filenames to images.) Set the image property in the second view controller and invoke it.
Regards,
Duncan C WareTo
Animated GIF created with Face Dancer, available for free in the app store.
I'm able to pick up the image now. But I am still not getting it in my Second View Controller.
Thoughts?
I have properties set for both the UIImage and UIImageView
Don't try to change another view controller's views directly. There are lots of reasons why that's bad. This is one... it doesn't work sometimes. Even in cases where it does work, it's bad design.
Create an image property in the second view controller, and set that.
Then, in your second view controller's viewWillAppear method, set the image view's image to the view controller's image property.
Regards,
Duncan C WareTo
Animated GIF created with Face Dancer, available for free in the app store.
Replies
UIView objects have a property call tag. It's an integer.
Set up each button with a different, non-zero tag number.
Have each button invoke the same action.
In that action, check the tag number of the button, and use that to look up the image.
Add a UIImage property to your second view controller.
In the button action, look up the image using the tag number (from an array of images perhaps, or an array of filenames to images.) Set the image property in the second view controller and invoke it.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeUsing a for loop?
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeI am trying this:
viewDidLoad:
In my Button Action:
In my Second View Controller I have this:
My image is still not getting set though.
Thoughts?
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeI'm able to pick up the image now. But I am still not getting it in my Second View Controller.
Thoughts?
I have properties set for both the UIImage and UIImageView
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeI needed to set my secondViewControler.image = image
Thanks for the help earlier Duncan :)
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeCreate an image property in the second view controller, and set that.
Then, in your second view controller's viewWillAppear method, set the image view's image to the view controller's image property.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome