Reputation: 315
I'm a beginner on iOS
programming and I'd like to know how can I control an UIImageView
content using a UISwitch
. I've done it in the same view but I want to control the UIImageView
which is in view 3 (on my case) with the UISwitch
which is in view 1.
Upvotes: 0
Views: 157
Reputation: 41642
So you need some object that knows about views 0,1,2. If they are in a tab bar or a navigation bar its pretty easy to get the array of view controllers, and assuming you know exactly where the view is int the array, you can get a reference to the controller. Alternately, you can have some other object (like the app controller) have knowledge of the views.
Your app is showing view 1 with the switch, and user changes the switch. Your IBAction in view1 then gets a reference to view3, and uses some method view3 provides to have it change the image to what you want to show.
Alternately, you can message an object like the appDelegate and ask it to tell view 3 to change its image to such and such.
Upvotes: 1