简体   繁体   中英

How to connect a textfield and a Picker View

its the annoying noob again!

So I was trying to develop a small app to check files on a folder.

The text field is your search field.

You have a picker view with 3 options

Folder A

Folder B

Search on Google.

I've got a question:

1: How do I connect the search field and the pick that the user chose to a button so when the user clicks the button, lets say the button searches the users input on google?

I've made the application for 2 views.

One where the user inputs the information and the other to display that information.

My code is going something like this..

- (IBAction)buttonSearch:(id)sender {


self.userSearch = self.searchField.text; ///Users input on the search field

NSString *searchString = self.userSearch;

///I know Im missing the connection to the button with the pickView, how could I do that too?////


///Here should be something like go to google(or whatever choice the user made on pickview) and put the string on the search bar and hit search/// <---How do I do this too..? *****



}
@end

Thanks for the help, I know its a pain to answer such stupid questions.... :/ Have a nice day!

If you're using interface builder to create your view make sure to create IBOutlets for the textfields/pickers/etc. so that you can get their values.

@property (nonatomic, strong) IBOutlet UITextfield *myTextField;

Now in interface builder right click your text field and select "NewReferencingOutlet" and drag to "File's Owner" you should see "myTextField" as an option. Once that is attached you can then get the value of the text field like this.

self.myTextField.text

It will be similar for the pickerView except instead of UITextField you will use UIDatePIcker or something similar...

Hope that helps ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM