我適應我的應用程序支持兩種iOS7和6原創的UITableView使用搜索欄
我使用了一個表視圖用於過濾的數據顯示一個搜索欄顯示在結果的UITableView。
但是,當我的搜索過濾,出現在原始數據表視圖之上的過濾數據的表視圖,因此它們重疊。
有沒有人有任何想法?
在此先感謝。
附上2張圖片:
- 沒有搜索。
- 隨着搜索(你可以看到,表視圖重疊)
編輯:
添加數據源方法
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == self.searchDisplayController.searchResultsTableView)
{
return arregloFiltrado.count;
}else{
return arreglo.count;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"CeldaLista" owner:self options:nil];
cell = celdaLista;
self.celdaLista = nil;
}
if (tableView == self.searchDisplayController.searchResultsTableView) {
[(UILabel*)[cell viewWithTag:1] setText: /*Name and surname*/];
[(UILabel*)[cell viewWithTag:2] setText: /*Other properties*/];
if ([[arregloFiltrado objectAtIndex:indexPath.row] objectForKey:@"photo"] == nil) {
[(UIImageView*)[cell viewWithTag:4] setImage:/*No image*/];
}
else{
[(UIImageView*)[cell viewWithTag:4] setImage:/*Photo*/];
}
} else {
[(UILabel*)[cell viewWithTag:1] setText:/*Name and surname*/];
[(UILabel*)[cell viewWithTag:2] setText:/*Other properties*/];
if ([[arreglo objectAtIndex:indexPath.row] objectForKey:@"photo"] == nil) {
[(UIImageView*)[cell viewWithTag:4] setImage:/*No image*/];
}
else{
[(UIImageView*)[cell viewWithTag:4] setImage:/*Photo*/];
}
}
return cell;
}
還有更多?如果你使用它有它自己的UITabelview一個UISearchDisplayController
- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView{
tableView.backgroundColor = [UIColor whiteColor];//color of search result table
}
粘貼您的表視圖數據源代碼 –
你使用兩個tableView嗎? –
你可以請你出示你的代碼嗎? –