无法点击搜索栏tableview单元格
问题描述:
我有一个包含名称数组的tableview。搜索栏可以完美地过滤表格视图中的名称。无法点击搜索栏tableview单元格
问题是didSelectRowAtIndexpath
点击搜索tableview单元格时没有被触发。你能帮我吗?
我错过了什么?我是否应该包含任何特殊的代表参与搜索tableview单元格单击。
以下是图片和代码。
-(void)search
{
nameArray = [[NSMutableArray alloc] init];
searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 160, 44)];
searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
searchDisplayController.delegate = self;
searchDisplayController.searchResultsDataSource = self;
self.tableViewFriendsList.tableHeaderView = searchBar;
}
- (void)searchDisplayController:(UISearchDisplayController *)controller
willShowSearchResultsTableView:(UITableView *)tableView
{
[tableView setRowHeight:70];
[tableView reloadData];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView == self.tableViewFriendsList) {
NSString *friendsID =[[[self.friendsDictionary objectForKey:@"data"] objectAtIndex:indexPath.row] objectForKey:@"id"];
[[FacebookHelper sharedFacebookHelper] postOnWallWithDelegate:self andID:friendsID];
}
if (tableView == self.searchDisplayController.searchResultsTableView) {
NSLog(@"I ve come here");
NSString *friendsID =[friendsListIdArray objectAtIndex:indexPath.row];
[[FacebookHelper sharedFacebookHelper] postOnWallWithDelegate:self andID:friendsID];
}
}
答
你忘了把
searchController.searchResultsDelegate = self;
答
我做我的项目,可能是有帮助的一个东西:
// add gesture to detect when table view is being tapped so that keyboard may be dismissed
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(dismissKeyboard)];
gestureRecognizer.cancelsTouchesInView = NO;
[self.tableView addGestureRecognizer:gestureRecognizer];
而且我很奇怪,为什么你有内表格单元格搜索栏。你介意在你的应用中发布一个屏幕截图吗?我担心你可能会做更多的工作。
+0
问题是我不是能火didSelectRowAtIndexPath方法为searchtable.when的searchtableview细胞被点击我没有问题驳回键盘...任何想法 – user578386 2012-07-28 06:42:19
感谢..that完全工作 – user578386 2012-07-28 09:44:51