Giter VIP home page Giter VIP logo

nhautocompletetextfield's Introduction

NHAutoCompleteTextField

You can find the brief details on blog here: http://journeytoios.wordpress.com/2015/01/03/nhautocompletetextfield/

and this control is also available here: https://www.cocoacontrols.com/controls/nhautocompletetextfield

Runtime View

How to integrate:

All you have to take care of the two protocols NHAutoCompleteTextFieldDataSourceDelegate and NHAutoCompleteTextFieldDataFilterDelegate, first one for preparing and dealing with the datasource and second one is to filter from the data source. Two protocols may help to turn this control into simple drop down and selection control.

@protocol NHAutoCompleteTextFieldDataFilterDelegate

@optional

/**
If you wants to filter out records. It should return YES.
*/
-(BOOL)shouldFilterDataSource:(NHAutoCompleteTextField
*)autoCompleteTextBox;

/**
This function will help out to keep the filtered records only.
*/
-(void)autoCompleteTextBox:(NHAutoCompleteTextField
*)autoCompleteTextBox didFilterSourceUsingText:(NSString *)text;

@end

@protocol NHAutoCompleteTextFieldDataSourceDelegate

@required;

/**
Depicts the items available in the list.
*/
- (NSInteger)autoCompleteTextBox:(NHAutoCompleteTextField
*)autoCompleteTextBox numberOfRowsInSection:(NSInteger)section;

/**
Create a customized cell as per your need.
*/
- (UITableViewCell *)autoCompleteTextBox:(NHAutoCompleteTextField
*)autoCompleteTextBox cellForRowAtIndexPath:(NSIndexPath *)indexPath;

@end

Include just one file in your view-controller:

#import "NHMainHeader.h"
@interface ViewController : UIViewController
{

}

Flexibility to control the drop down direction of the control:

typedef enum
{
NHDropDownDirectionUp,
NHDropDownDirectionDown

} NHDropDownDirection;

Example:

- (void)viewDidLoad
{
[super viewDidLoad];

autoCompleteTextField = [[NHAutoCompleteTextField alloc]
initWithFrame:CGRectMake((kScreenSize.width - controlWidth) / 2, 120,
controlWidth, 18)];
[autoCompleteTextField setDropDownDirection:NHDropDownDirectionDown];
[autoCompleteTextField setDataSourceDelegate:self];
[autoCompleteTextField setDataFilterDelegate:self];
}

#pragma mark - NHAutoComplete DataSource delegate functions

- (NSInteger)autoCompleteTextBox:(NHAutoCompleteTextField
*)autoCompleteTextBox numberOfRowsInSection:(NSInteger)section
{

}

- (UITableViewCell *)autoCompleteTextBox:(NHAutoCompleteTextField
*)autoCompleteTextBox cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

}

#pragma mark - NHAutoComplete Filter data source delegate functions

-(BOOL)shouldFilterDataSource:(NHAutoCompleteTextField
*)autoCompleteTextBox
{

}

-(void)autoCompleteTextBox:(NHAutoCompleteTextField
*)autoCompleteTextBox didFilterSourceUsingText:(NSString *)text
{

}

nhautocompletetextfield's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.