Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

iOS Advice

Hi everyone!

Could someone explain an iOS concept to me please? I always get confused about how to implement the following idea:

I have a root view controller with a scroll view. The scroll view contains child views, containing a single button. I need my root view controller to know when someone taps the buttons.

Have I missed anything in the videos?

Cheers, George

1 Answer

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

If you are using Interface Builder then you can simply define an IBAction and connect your button to the root view controller. For more info, check out this video: Buttons and IBAction

If you want to add an action programmatically then you can use this method: addTarget:action:forControlEvents: