Reputation: 737
In this game that I am building, I want to be able to change the image in a different view. I want to do this because there are some many different images to choose from and I want to organize them in a different view. So how can I do this?
In the first view i have 1 image view + a button to go the the view to change the image. In the second view i have some images with a transparent button over them (so i can click them), it will bring back the player when it is click. All i need now is to change the image in the first view when one of the button is clicked in the seconds view.
Upvotes: 0
Views: 146
Reputation: 3598
You can use a delegate protocol. This way you can tell the delegate that something has happened and it can then respond accordingly.
Lets say that you have a UIViewController and 2 views. One view might declare a delegate protocol like
@protocol MyViewDelegate <NSObject>
- (void)myView:(MyView *)view didPickImage:(UIImage*)image;
@end
Your view controller might implement this protocol and when the user selects the image you can call
[delegate myView:self didPickImage:image];
The viewController would then set the image in your other view.
Upvotes: 4