Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Updated 26 October 2021
Sometimes we need to give the single selection from multiple data on UItextfield , when the user tap on UIText Field. For this there is new accessory view provided by swift through we can add UIPicker view and UITextfield.
For doing this , we need to follow some steps:
open .swift file and
1: create a outlet of UITextfiled
ex:
@IBOutlet weak var withoutAirGoCountryTextField1: UITextField!
2: Now create the IBAction of UITextfield and set event didbeginediting. and set the picker view like that
3: Now its time to add the toolbar on this picker view so we can give some functionality like cancel or anything;
for this go to ViewDidload method and write that code:
Note: here
GoCountriesSearch is existing swift class name and their method
“donePressed” ,Now its time to define this method:
it will remove the picker view .
4: Now we have to write the delegate method of UIPickerView:
a: in class add two delegate of picker view
and their delegate metod:
b: Now set the data to UItextField:
5: Now when you scroll the UIPicker View it automatically set the data to UITextField
6: Now the last and important point , How to fetch the selected row in UIView for this
a: create a button like findData
and write this code:
Happy coding
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.