Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hackiftekhar/IQDropDownTextField
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: fjsosa/IQDropDownTextField
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 5 commits
  • 4 files changed
  • 1 contributor

Commits on Apr 6, 2015

  1. Explicit date/time mode

    Adding a explicit date time mode.
    fjsosa committed Apr 6, 2015
    Copy the full SHA
    88ea22d View commit details

Commits on Nov 5, 2015

  1. Changes made in the LHR Mobile

    Changes made in the LHR Mobile
    fjsosa committed Nov 5, 2015
    Copy the full SHA
    0852db2 View commit details
  2. PodSpec Updated

    PodSpec Updated
    fjsosa committed Nov 5, 2015
    Copy the full SHA
    bad0ece View commit details

Commits on Dec 18, 2017

  1. Merge remote-tracking branch 'upstream/master'

    # Conflicts:
    #	IQDropDownTextField Demo/Drop Down TextField/ViewController.m
    #	IQDropDownTextField.podspec
    #	IQDropDownTextField/IQDropDownTextField.h
    #	IQDropDownTextField/IQDropDownTextField.m
    fjsosa committed Dec 18, 2017
    Copy the full SHA
    2c89259 View commit details
  2. Fixing merges

    fjsosa committed Dec 18, 2017
    Copy the full SHA
    4af157a View commit details
4 changes: 4 additions & 0 deletions Drop Down TextField.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
E609C876182ECB1D0058DB63 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E609C875182ECB1D0058DB63 /* main.m */; };
E609C87A182ECB1D0058DB63 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E609C879182ECB1D0058DB63 /* AppDelegate.m */; };
E609C883182ECB1D0058DB63 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E609C882182ECB1D0058DB63 /* ViewController.m */; };
EDD90A691FE81A8F0089E10B /* IQDropDownTextField in Resources */ = {isa = PBXBuildFile; fileRef = EDD90A681FE81A8F0089E10B /* IQDropDownTextField */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
@@ -41,6 +42,7 @@
E609C879182ECB1D0058DB63 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
E609C881182ECB1D0058DB63 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
E609C882182ECB1D0058DB63 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
EDD90A681FE81A8F0089E10B /* IQDropDownTextField */ = {isa = PBXFileReference; lastKnownFileType = folder; path = IQDropDownTextField; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
@@ -107,6 +109,7 @@
E609C86F182ECB1D0058DB63 /* Drop Down TextField */ = {
isa = PBXGroup;
children = (
EDD90A681FE81A8F0089E10B /* IQDropDownTextField */,
E609C878182ECB1D0058DB63 /* AppDelegate.h */,
E609C879182ECB1D0058DB63 /* AppDelegate.m */,
E609C881182ECB1D0058DB63 /* ViewController.h */,
@@ -190,6 +193,7 @@
4CC1D5D61F7FA748007595D9 /* LaunchScreen.storyboard in Resources */,
E609C874182ECB1D0058DB63 /* InfoPlist.strings in Resources */,
39DD82711CFC666A0006FA8E /* Montserrat-Regular.otf in Resources */,
EDD90A691FE81A8F0089E10B /* IQDropDownTextField in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
54 changes: 54 additions & 0 deletions IQDropDownTextField Demo/Drop Down TextField/ViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// ViewController.m
// Drop Down TextField
//
// Created by hp on 10/11/13.
// Copyright (c) 2013 Iftekhar. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];

UIToolbar *toolbar = [[UIToolbar alloc] init];
[toolbar setBarStyle:UIBarStyleBlackTranslucent];
[toolbar sizeToFit];
UIBarButtonItem *buttonflexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *buttonDone = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneClicked:)];

[toolbar setItems:[NSArray arrayWithObjects:buttonflexible,buttonDone, nil]];
textFieldDatePicker.inputAccessoryView = toolbar;
textFieldTextPicker.inputAccessoryView = toolbar;
textFieldTimePicker.inputAccessoryView = toolbar;
textFieldOptionalTextPicker.inputAccessoryView = toolbar;

textFieldTextPicker.isOptionalDropDown = NO;
[textFieldTextPicker setItemList:[NSArray arrayWithObjects:@"London",@"Johannesburg",@"Moscow",@"Mumbai",@"Tokyo",@"Sydney", nil]];
[textFieldOptionalTextPicker setItemList:[NSArray arrayWithObjects:@"London",@"Johannesburg",@"Moscow",@"Mumbai",@"Tokyo",@"Sydney", nil]];

[textFieldDatePicker setDropDownMode:IQDropDownModeDatePicker];

[textFieldTimePicker setDropDownMode:IQDropDownModeDateTimePicker];
// Do any additional setup after loading the view, typically from a nib.
}

-(void)doneClicked:(UIBarButtonItem*)button
{
[self.view endEditing:YES];
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end
12 changes: 12 additions & 0 deletions IQDropDownTextField.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Pod::Spec.new do |s|
s.name = "IQDropDownTextField"
s.version = "1.0.4"
s.summary = "TextField with DropDown support using UIPickerView"
s.homepage = "https://github.com/hackiftekhar/IQDropDownTextField"
s.license = 'MIT'
s.author = { "Iftekhar Qurashi" => "hack.iftekhar@gmail.com" }
s.platform = :ios, '5.0'
s.source = { :git => "https://github.com/fjsosa/IQDropDownTextField", :tag => "v 1.0.4" }
s.source_files = 'Classes', 'IQDropDownTextField/*.{h,m}'
s.requires_arc = true
end
62 changes: 60 additions & 2 deletions IQDropDownTextField/IQDropDownTextField.m
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@ @interface IQDropDownTextField () <UIPickerViewDelegate, UIPickerViewDataSource>
@property (nonatomic, strong) UIToolbar *dismissToolbar;

@property BOOL hasSetInitialIsOptional;

@end


@@ -138,6 +137,7 @@ - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSIn
return self.internalItemList.count;
}


#pragma mark UIPickerView delegate

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
@@ -154,13 +154,39 @@ - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forC
{
UILabel *labelText = (UILabel*)view;

/* WORKAROUND FSO
* We need to find a point to select the default option to the control, if we select the default opcion
* before the picker view is showed, the textbox will show that opcion as default, and we need the field empty
* until the user pick the control. Once the user picked the control, the pickerview is showed
* with a default value. and the textbox should reflect that selection.
* Rememeber that this control is not a picker view, is a textbox that contains a picker view.
* and the picker view is a sub control, as the pickerview control does not have any method or event
* that allow notify us when that control is loaded (in fact, there are serveral methods in UIView, but we
* need a sub class, and this change implies a big change in the pod control.
*
* The only point I found to set the default values when the pickerview is showed is this one. but this
* method is run for each row in the picker view, this is the reason for the first validation in the "if"
* statement, just to avoid reset the selected item in each method call.
*/
if(self.selectedItem == nil && _ItemListsInternal.count > 0)
{
[self setSelectedItem:_ItemListsInternal[0]];
}
//END FSO


if (labelText == nil)
{
labelText = [[UILabel alloc] init];
[labelText setTextAlignment:NSTextAlignmentCenter];
[labelText setAdjustsFontSizeToFitWidth:YES];
labelText.backgroundColor = [UIColor clearColor];
labelText.backgroundColor = [UIColor clearColor];
}else{
//FSO
labelText.font = [UIFont boldSystemFontOfSize:20.0];
labelText.textColor = [UIColor blackColor];
//END FSO
}

NSString *text = [self.internalItemList objectAtIndex:row];
@@ -284,13 +310,18 @@ - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComp
}
}

- (void)dateTimeChanged:(UIDatePicker *)tPicker
{
[self setSelectedItem:[self.dropDownDateTimeFormatter stringFromDate:tPicker.date]];
}

#pragma mark - Selected Row

- (NSInteger)selectedRow
{
if (self.isOptionalDropDown)
{
return [self.pickerView selectedRowInComponent:0]-1;
return [self.pickerView selectedRowInComponent:0] - 1;
}
else
{
@@ -403,6 +434,9 @@ - (void)setDropDownMode:(IQDropDownMode)dropDownMode
self.inputView = nil;
}
break;
case IQDropDownModeDateTimePicker:
self.inputView = self.dateTimePicker;
break;
default:
break;
}
@@ -465,6 +499,7 @@ - (NSString*)selectedItem
}
break;
}
>>>>>>> upstream/master
}

-(void)setSelectedItem:(NSString *)selectedItem
@@ -557,6 +592,9 @@ - (void) _updateOptionsList {
// [self setSelectedRow:self.selectedRow];
}
break;
case IQDropDownModeDateTimePicker:
[self setSelectedItem:[self.dropDownDateTimeFormatter stringFromDate:date] animated:animated];
break;
default:
break;
}
@@ -670,6 +708,25 @@ -(NSDate *)date
return [self.datePicker.date copy];
}
}

case IQDropDownModeDateTimePicker:
{
NSDate *date = [self.dropDownDateTimeFormatter dateFromString:selectedItem];
if (date)
{
_selectedItem = selectedItem;
self.text = selectedItem;
[self.dateTimePicker setDate:date animated:animated];

if ([self.delegate respondsToSelector:@selector(textField:didSelectItem:)])
[self.delegate textField:self didSelectItem:_selectedItem];
}
else if ([selectedItem length])
{
NSLog(@"Invalid date or date format:%@",selectedItem);
}
break;
}
case IQDropDownModeTimePicker:
{
if (self.isOptionalDropDown)
@@ -739,6 +796,7 @@ -(UIDatePickerMode)datePickerMode

- (void)setDatePickerMode:(UIDatePickerMode)datePickerMode
{

if (self.dropDownMode == IQDropDownModeDatePicker)
{
objc_setAssociatedObject(self, @selector(datePickerMode), @(datePickerMode), OBJC_ASSOCIATION_RETAIN_NONATOMIC);