TextField with DropDown support using UIPickerView

Overview

IQDropDownTextField

TextField with DropDown support using UIPickerView

Sample

Installing

Install using cocoapods. Add in your Podfile:

pod 'IQDropDownTextField'

Swift Projects

Add the .h file in your bridging header

#import "IQDropDownTextField.h"

How to Use

In IB (story boards or xibs) you can add UITextField's and set the class as IQDropDownTextField

Objective-C

Nothing more easy than it!

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    textFieldTextPicker.isOptionalDropDown = NO;
    [textFieldTextPicker setItemList:[NSArray arrayWithObjects:@"London",@"Johannesburg",@"Moscow",@"Mumbai",@"Tokyo",@"Sydney", nil]];
}
@end

Swift

It's very simple to setup your IQDropDownTextField. The sample below shows you how to:

class MyController : UIViewController {
  @IBOutlet weak var occupationTextField: IQDropDownTextField!
  
  override func viewDidLoad() {
    occupationTextField.isOptionalDropDown = false
    occupationTextField.itemList = ["programmer", "teacher", "engineer"]
  }
}

And that's all you need! =)

Contributions

Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.

Author

If you wish to contact me, email at: [email protected]

LICENSE

Copyright (c) 2010-2015

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • CALayerInvalidGeometry; CALayer bounds contains NaN: [...]

    CALayerInvalidGeometry; CALayer bounds contains NaN: [...]

    Thank you so much for making wonderful library.

    App some time crash. I have attached fabric screen short.

    IQDropDownTextField.m line 321 -[IQDropDownTextField setSelectedRow:animated:]

    screen shot 2017-10-12 at 11 37 58 am

    Thank You.

    opened by mitulmarsonia 24
  • setting formatter to date picker not working

    setting formatter to date picker not working

    i'm setting the formatter to a dropdown in datepicker mode.it show the correct format in textfield when a date is selected but not showing new format in dropdown gear screen shot 2017-04-17 at 7 12 38 pm

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"EEE MMMM dd yyyy"]; [cell.txtBeginningDay setDateFormatter:formatter]; cell.txtBeginningDay.dropDownMode = IQDropDownModeDatePicker; cell.txtBeginningDay.isOptionalDropDown = YES;

    enhancement question wontfix 
    opened by sameer4 11
  • The method of UITextFieldDelegate won't work

    The method of UITextFieldDelegate won't work

    For 1.0.5 the IQDropDownTextField just delegate its own delegate method -(void)textField:(IQDropDownTextField*)textField didSelectItem:(NSString*)item;, all method in UITextFieldDelegate won't work.

    I already create a pull request to fix this.https://github.com/hackiftekhar/IQDropDownTextField/pull/20 Hope this fix can bump to 1.0.5.1 ASAP for cocoapod.

    bug 
    opened by bestwnh 11
  • setMinimumDate not working after new pod update

    setMinimumDate not working after new pod update

    setMinimumDate not working after new pod update.

    No visible @interface for 'BHDropDownTextField' declares the selector 'setMinimumDate:'

    NSDate *minimumDate = [NSDate date]; [self.tfDate setMinimumDate:minimumDate];

    opened by hasidil 9
  • Impossible to make an action when value change

    Impossible to make an action when value change

    I would like to call a method when the value is change (in order to enable a button when something is selected in pickerView) but nothing seems to work, do you have any idea? I tried this: [_TextFieldPicker addTarget:self action:@selector(checkFields) forControlEvents:UIControlEventValueChanged];

    opened by OxyFlax 8
  • Button dont you see the first time

    Button dont you see the first time

    The problem is in ios 11, the toolbar not have button done, i need touch two times mi code

    func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { if PaymentsSearchBar.countOpenDate < 4 { PaymentsSearchBar.countOpenDate = PaymentsSearchBar.countOpenDate + 1 textField.reloadInputViews() textField.keyboardToolbar.sizeToFit() textField.sizeToFit() textField.keyboardToolbar.reloadInputViews() textField.resignFirstResponder() } return true }

    opened by fsaldivarids 6
  • Dropdown not working since .text was deprecated

    Dropdown not working since .text was deprecated

    I changed my .text to .selectedItem and now the dropdown menu doesn't activate when tapped anymore. I checked this on my device and on simulator. Here is my sample code to initiate the dropdown:

    -(void)textFieldDidBeginEditing:(UITextField *)textField {
        [self.messageField becomeFirstResponder];
        self.messageField.tintColor = [UIColor redColor];
    
         if ([textField.placeholder isEqualToString:@"Your message"]) {
          self.messageField.placeholder = @"";
          self.previewLabel.text = self.messageField.text;
        } else if (textField == self.messageField){
             [self.previewLabel setFont:[UIFont fontWithName:self.fontTextField.selectedItem size:[self.sizeTextField.selectedItem floatValue]]];
            self.previewLabel.text = self.messageField.text;
        }
    }
    

    Any ideas on how to fix this? Any help would be greatly appreciated. Thanks!

    bug 
    opened by parkerdonat 6
  • TextField's text on init

    TextField's text on init

    I think that the textfield should init with "", not the first item on the array. With this, the user can see the Placeholder before tapping on the textfield.

    What do you think?

    By the way, our repo ROCKS!

    opened by lfarah 6
  • commit with time picker added

    commit with time picker added

    i have used this control in one of my project, and i needed support for time picker , so i have modified it with time picker support.

    Thanks for this code!!!

    opened by pawankmrai 6
  • Time zone issue when using timePicker

    Time zone issue when using timePicker

    Hi!

    I'm experiencing the following issue:

    My device is set to CEST time zone (UTC +2), but when i select time from time picker drop down, time is being stored in UTC +1 time zone. Now, i'm not 100% percent sure this issue occurs because there's something wrong with the library, but is there a chance that there might be something wrong? Could you look into it?

    Best regards!

    opened by kristiansu 5
  • selectedItem not nil

    selectedItem not nil

    case IQDropDownModeDatePicker: { return [self.dropDownDateFormatter stringFromDate:self.datePicker.date]; }

    while I didn't select any items, it always return the current date

    bug 
    opened by codwam 5
  • IQDropDownTextField setSelectedItem - Default value does not show in picker

    IQDropDownTextField setSelectedItem - Default value does not show in picker

    Step 1. [textFieldOptionalTextPicker setItemList:[NSArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5",@"6", nil]]; Step 2: [textFieldOptionalTextPicker setSelectedItem:@"4"]; Step 3: TextField shows the last selected value, but does not select that value in picker. Also, when trying to retrieve textfield's value by using textFieldOptionalTextPicker.selectedItem, it returns nil.

    Environment: OS: Version 12.2 (21D49) Xcode: Version 13.2.1 (13C100)

    opened by ArshdeepTrantor 1
  • Add SwiftPM support

    Add SwiftPM support

    • Add Github actions for continuous-integration. Actions will take into affect immediately as shown on my fork: https://github.com/master-nevi/IQDropDownTextField/actions
    • Updates .gitignore to ignore some SwiftPM artifacts
    • Bump version to 3.1.0
    opened by master-nevi 4
  • CALayer bounds contains NaN: [0 nan; 320 291]

    CALayer bounds contains NaN: [0 nan; 320 291]

    we are using v2.0. but still encounter this CAlayer crash as below. Is it possible to keep on investigate it and fix it? Thanks!

    libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [0 nan; 320 291]. Layer: <CALayer:0x283c19480; position = CGPoint (151 16.8333); bounds = CGRect (0 -129.667; 320 291); delegate = <UIPickerTableView: 0x116520200; frame = (-9 -128.667; 320 291); opaque = NO; gestureRecognizers = <NSArray: 0x2832bff30>; layer = <CALayer: 0x283c19480>; contentOffset: {0, -129.66666666666666}; contentSize: {320, 0}; adjustedContentInset: {129.66666666666666, 0, 129.33333333333334, 0}; dataSource: <UIPickerColumnView: 0x1168ae430; frame = (9 0; 302 216); autoresize = W+TM+H; gestureRecognizers = <NSArray: 0x2832ba160>; layer = <CALayer: 0x283c07220>>>; sublayers = (<CALayer: 0x283c4d820>, <CALayer: 0x283c3b3e0>); allowsGroupOpacity = YES; backgroundColor = (null)>'
terminating with uncaught exception of type NSException
(Recorded stack frame)

    opened by ycwjjjj 0
  • Need support for mac app , Xcode 11

    Need support for mac app , Xcode 11

    We are converting our iOS app to mac in xCode 11 beta, in that we face issue related to UI.

    Date picker not show in that, can you please help for the same.

    opened by Hardiktspaceo 0
Owner
Mohd Iftekhar Qurashi
Everyone has their own strength, weakness and unique skills, that's what make them special.
Mohd Iftekhar Qurashi
Floating-textfield-swiftui - Floating textfield With SwiftUI

floating_textfield-swiftui Hey, Guys welcome to this tutorial. In this complete

null 1 Feb 11, 2022
DTTextField is a custom textfield with floating placeholder and error label

DTTextField Introduction DTTextField is a UITextField library with floating placeholder and error label. Floating placeholder inspired from JVFloatLab

Dhaval Thanki 310 Jan 5, 2023
Floating Label TextField for SwiftUI. FloatingLabelTextFieldSwiftUI

FloatingLabelTextFieldSwiftUI FloatingLabelTextFieldSwiftUI is a small and lightweight SwiftUI framework written in completely swiftUI (not using UIVi

Kishan Raja 337 Jan 2, 2023
A custom TextField with a switchable icon which shows or hides the password and enforce good password policies

PasswordTextField A custom TextField with a switchable icon which shows or hides the password and enforces good password policies, written in Swift. ⭐

Chris Jimenez 304 Dec 29, 2022
A SwiftUI TextField with a prompt (or placeholder) that floats above the text field when active or not empty. Requires iOS 15.

FloatingPromptTextField A prompt is the label in a text field that informs the user about the kind of content the text field expects. In a default Tex

Emilio Peláez 43 Nov 3, 2022
A floating label style for SwiftUI's TextField.

FloatingLabelTextFieldStyle A floating label style for TextField with support for displaying error messages. Requirements iOS 15.0+ macOS 12.0+ Instal

Red Davis 13 Aug 22, 2022
Simple placeholder move textfield

PlaceholderTextField Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 11.0 o

null 6 Mar 9, 2022
Elegant SwiftUI phone number textField.

iPhoneNumberField ☎️ Format phone numbers as they're typed—entirely in SwiftUI. ?? Get Started | Examples | Customize | Features | Install | And it's

Seyed Mojtaba Hosseini Zeidabadi 358 Dec 30, 2022
An optional TextField Replacement for SwiftUI

TextInputView A TextField Replacement In his excellent YouTube tutorial series on Building SwiftUI Components, Peter Friese (@peterfriese on Twitter)

Stewart Lynch 6 Aug 9, 2022
This is the demo repository for having floating TextField in swift UI

ed-floating-field-swiftui This is the demo repository for having floating TextField in swift UI The inputs fields should not be empty Validations for

Patrick 1 May 26, 2022
TextField with smart suggestion

AutoCompleteTextField Features Provides a subclass of UITextField that has suggestion from input Has autocomplete input feature Data suggestion are pr

Neil Francis Ramirez Hipona 63 Nov 13, 2022
Library that allows you binding `enabled` property of button with textable elements (TextView, TextField)

What is NxEnabled? It's a fairly common case, when the enabled state of button depends on some textable elements such as TextView, TextField. So this

Nikita Ermolenko 33 Sep 20, 2021
Awesome TextField is a nice and simple libriary for iOS and Mac OSX

Awesome TextField is a nice and simple libriary for iOS and Mac OSX. It's highly customisable and easy-to-use tool. Works perfectly for any registration or login forms in your app.

Alexander Shoshiashvili 225 Nov 21, 2022
Apple TextField created according to the Material.IO guidelines of 2019. Featured at Medium.

CocoaTextField Highly customizable text field created according to Material.IO guidelines. Minimum iOS version 11.0 Carthage github "edgar-zigis/Cocoa

Edgar Žigis 266 Nov 26, 2022
TTextField is developed to help developers can initiate a fully standard textfield including title, placeholder and error message in fast and convinient way without having to write many lines of codes

TTextField is developed to help developers can initiate a fully standard textfield including title, placeholder and error message in fast and convinient way without having to write many lines of codes

Nguyen Duc Thinh 7 Aug 28, 2022
Provides a SwiftUI multi-line TextView implementation including support for auto-sizing. (iOS)

TextView Also available as a part of my SwiftUI+ Collection – just add it to Xcode 13+ Provides a SwiftUI multi-line TextView implementation with supp

SwiftUI+ 51 Jan 3, 2023
A light-weight UITextView subclass that adds support for placeholder.

RSKPlaceholderTextView A light-weight UITextView subclass that adds support for placeholder. Installation Using Swift Package Manager To add the RSKPl

Ruslan Skorb 220 Dec 17, 2022
UITextField that support currency in the right way.

PLCurrencyTextField Summary PLCurrencyTextField provides simple and user friendly support for the amount in the currency. Usage To start using the com

Łukasz Śliwiński 96 Nov 14, 2022
A UITextView subclass that adds support for multiline placeholder written in Swift.

KMPlaceholderTextView A UITextView subclass that adds support for multiline placeholder written in Swift. Usage You can set the value of the placehold

Zhouqi Mo 795 Nov 18, 2022