tableView下拉出现搜索栏的,小问题 搜索 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我写的,不怎么好使,希望给你点启示。- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *cellId=@"cellid"; UILabel* label = nil; UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellId]; if (cell==nil) { cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]autorelease]; label = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 100, 30)]; label.tag = 999; label.backgroundColor = [UIColor redColor]; label.hidden = YES; [self.view addSubview:label]; }else{ flage = !flage; UILabel* label = (UILabel*)[self.view viewWithTag:999]; if (flage) { label.hidden = NO; }else{ label.hidden = YES; } } //cell.textLabel.text=[self.listData objectAtIndex:[indexPath row]]; return cell; 将UISearchBar 当作UITableView的headerView添加到UITableView中去 _searchBar = [[PBSearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44.0f)]; _searchBar.placeholder = NSLocalizedString(@"Please enter route name", @"请点击输入线路名称"); _searchBar.delegate = self; [self.view addSubview:_searchBar]; _tableView = [[PBListTableView alloc] initWithFrame:CGRectMake(0, 50, self.view.bounds.size.width, self.view.bounds.size.height - 50.0)]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.tableHeaderView = _searchBar; [self.view addSubview:_tableView];把UITableView的tableHeaderView设置成UISearchBar的实例就行了。 https://github.com/fabiankr/TableViewSearchBar iPhone接入分享到微信朋友圈求助 IOS UIWebView 登录问题,求各位大佬帮帮忙!! ios 6中如何禁止横屏 好奇怪的问题! uitablecell中的uiimageview ,有的响应gesture recognizer,有的不响应 使用UIPopoverController 弹出 UISplitViewController 的问题? sql语句为什么执行没效果呢,也不报错 新手求助帖 急急急!! 主线程等待block执行结果后执行 企业级证书打包的App怎么禁止访问沙盒文件 ios使用java-APN推送报错,求支援 iOS 前台和后台交互问题 iOS 前台和后台交互问题
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellId=@"cellid";
UILabel* label = nil;
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellId];
if (cell==nil) {
cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]autorelease];
label = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 100, 30)];
label.tag = 999;
label.backgroundColor = [UIColor redColor];
label.hidden = YES;
[self.view addSubview:label];
}else{
flage = !flage;
UILabel* label = (UILabel*)[self.view viewWithTag:999];
if (flage) {
label.hidden = NO;
}else{
label.hidden = YES;
} }
//cell.textLabel.text=[self.listData objectAtIndex:[indexPath row]];
return cell;
_searchBar = [[PBSearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44.0f)];
_searchBar.placeholder = NSLocalizedString(@"Please enter route name", @"请点击输入线路名称");
_searchBar.delegate = self;
[self.view addSubview:_searchBar];
_tableView = [[PBListTableView alloc] initWithFrame:CGRectMake(0, 50, self.view.bounds.size.width, self.view.bounds.size.height - 50.0)];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.tableHeaderView = _searchBar;
[self.view addSubview:_tableView];
把UITableView的tableHeaderView设置成UISearchBar的实例就行了。