After a long gap, I made a time off from my regular stuffs to write here few
things. This time I choosed a topic
“Auto Search/Auto Complete” ,. You guyz already knew about this feature
, if not, then auto search/Auto complete is the process of searching when you
type some character in Search field. Auto search simply detects each of the
character you type and starts searching. Moreover, When a user is
entering data into a text field, it’s often nice to have the ability to auto
complete with custom values based on what the user is entering, saving their
time.
Auto Search the
name, always sounds complicated . Even I always thought doing auto search
features in iOS app must be complicated but I was wrong . It is not hard as it
sounds, and how I figured it out , I am explaining here with simply using
UItextField and its native method.
Here are the step by step guidelines :
1.
First thing you need to create is UITextField
which works as a search bar and UITableView for displaying your search results.
And another thing is data source (Array/Dictionary) which has a collection of
data from where we need to search based
on the name/strings which user types in text field.
2.
You can play with UItableView in your own way. You simply can hide it first
and when starts searching and finds result , you can unhide the table and
reload the data. OR simply you can only add table view when search starts and
remove it when we are done with the selection.
Here, I am using Hidden property
of UItableView.
3.
Create UITextField , define
<UITextFieldDelegate> in you .h file