Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Garrett Cox
Garrett Cox
4,797 Points

UISwitch to make text field appear

I am hoping to have a switch, that once the state is changed, a text field will appear for the user to input text.

This will be for an app that can lookup their location, but if they move the switch, they could then enter in an address instead.

There seem to people minimal resources on the UIswitch that involve something like that.

2 Answers

Kieran Robinson
Kieran Robinson
9,411 Points

Hiya mate, https://drive.google.com/file/d/0B4qNq90-3k9CX0xaano0eWRrenc/edit?usp=sharing thats a link to a project i made to show you a very simple example of this. Hope it helps, Kieran

The UISwitch has a delegate method called "valueChanged" you could possibly use that. Based on whatever the value is, in that method, show or hide the textfield.