Subscribe ( )

iPhone Programming Tutorials


 

Forum

You must be logged in to post Login Register

Search 

UISearchBar help

User Post

4:27 pm
September 19, 2008


Colonial94

Noob

posts 3

1

I'm trying to use UISearchBar to search for the appropriate rows in a UITableView, but I apparently don't have the UISearchBar set up correctly (the delegate methods I have created aren't being invoked by the events in the UISearchBar that is included in the view).  I looked over the simple table search example provided by apple, but they seem to use interface builder to set up the search bar, and I can't figure out how to set up the relationships correctly.

Has anyone else got this working?  Any ideas on how to get it working correctly?

Disclaimer:  I am still relatively new to Objective-C, so this very well could be a simple fix.  I'm guessing I'm not setting up the search bar delegates correctly, which is still something I don't totally understand.

8:38 pm
September 21, 2008


iCoder

Sydney, Australia

posts 7

2

First of all, you need to connect the 'delegate' wiring of your UISearchBar in the Interface Builder to your ViewController.

Then in the header file for your view controller, on the line that starts with @interface, after the base class but before the { you should add <UISearchBarDelegate> (or just put UISearchBarDelegate between the existing < and > if there are any). What you're doing is telling the view controller class that it supports the protocol for being a UISearchBarDelegate.

Then you need to implement some methods in your view controller main file. Which ones you implement is up to you, but here's what I had implemented (in an app that is currently in review for the AppStore):

  • searchBarTextDidBeginEditing: will be called when the user starts editing the search bar text
  • searchBarTextDidEndEditing: will be called when the user finishes editing the search bar text
  • searchBar:textDidChange: will be called when the user changes the text in the search bar (every key stroke)
  • searchBarCancelButtonClicked: will be called when the cancel button in the search bar is pressed
  • searchBarSearchButtonClicked: will be called when the search button in the search bar is clicked.

1:27 pm
November 8, 2008


slipgrid

Noob

posts 1

3

Thank you

Search 

About the iCodeBlog forum

Most Users Ever Online:

44


Currently Online:

4 Guests

Forum Stats:

Groups: 2

Forums: 6

Topics: 419

Posts: 893

Membership:

There are 935 Members

There has been 1 Guest

There are 2 Admins

There is 1 Moderator

Top Posters:

bobcubsfan – 54

crazyiez – 30

Uhu – 17

AdeC – 17

Nick – 15

jitesh61 – 12

Administrators: Brandon (88 Posts), Collin (0 Posts)

Moderators: VertigoSol (26 Posts)



©   

  • Posted by on 6 Aug 2008 in Uncategorized
  •   |  
  •   |  
  •   |  
  • Comments Off

Comments are closed.