today I created a tableView, similar to the iPhone Contacts app. I placed a TableView into the first cell, using the code
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([indexPath indexAtPosition:0] == 0) {
static NSString *CellIdentifier = @"SearchCell";
UITableViewCell *searchBarCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
searchBar = [[UISearchBar alloc] initWithFrame:searchBarCell.frame];
[searchBarCell addSubview:searchBar];
return searchBarCell;
} // ...
The searchBar displays correctly, but when I implemented the search methods, I found that they are not being entered when I type into the searchBar… for example this method:
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchTerm
I think it is because the searchBar is a subview of another class, the tableView Cell? Thats why the search bar can’t access the search methods? I also set the search bar delegate to self, still nothing.
Can any body help?
Thanks a lot in advance 🙂
You are not setting the delegate of your UISearchBar. I read in a comment you did it in other part, but you have to do it after you create the object. I mean after the line: