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

Adding a search field programatically .

I was making a small extra credit for the photo bombers app in the iOS development. My question is how do u add a search box programatically and get the NSString value from the typed string and put that variable in the viewController of the main url of the instagram page where we fetch all the pictures. We can add this variable value in that.

2 Answers

  1. Create a UITextField: UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(x, y, width, height)];
  2. Add textField to an existing view or create a new view and add it
  3. Get the value from the textfield with something like: NSString *searchValue = textField.text;

You said in your second step that we should add a textField to a view. But this is done using the storyboard but in the photo bombers app they did everything programatically.

Thanks.