검색 표시 줄에이 코드를 사용하고 있지만 결과가 표시되지 않습니다.검색 표시 줄이 작동하지 않습니다 iPhone Xcode 4.2
filteredListitems = [[NSMutableArray alloc] initWithArray:listVehicles];
검색 창 방법 :있는 viewDidLoad 방법에서
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
if ([searchText length] == 0) {
[filteredListitems removeAllObjects];
[filteredListitems addObjectsFromArray:listVehicles];
}else {
[filteredListitems removeAllObjects];
for (NSString * string in listVehicles) {
NSRange r = [string rangeOfString:searchText options:NSCaseInsensitiveSearch];
if (r.location != NSNotFound) {
[filteredListitems addObject:string];
}
}
}
[listTable reloadData];}
-(void)searchBarSearchButtonClicked:(UISearchBar *)aSearchBar {
[searchBar resignFirstResponder];
}
각 셀에 대한 코드는 다음
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"vlCell";
VehicleListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSLog(@"Cell Created");
NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"VehicleListCell" owner:nil options:nil];
for (id currentObject in nibObjects) {
if ([currentObject isKindOfClass:[VehicleListCell class]]) {
cell = (VehicleListCell *)currentObject;
}
}
UILongPressGestureRecognizer *pressRecongnizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(tableCellPressed:)];
pressRecongnizer.minimumPressDuration = 0.5f;
[cell addGestureRecognizer:pressRecongnizer];
[pressRecongnizer release];
}
cell.textLabel.font = [UIFont systemFontOfSize:10];
[[cell ignition] setImage:[UIImage imageNamed:@"ignition.png"]];
[[cell direction] setImage:[UIImage imageNamed:@"south.png"]];
NSString *cellValue = [filteredListitems objectAtIndex:indexPath.row];
cell.licPlate.text = cellValue;
return cell;
}는
I 검색 바 시도했다 디스플레이 컨트롤러, w 잘 작동하지만 필터링 된 검색 결과에 대한 자신의 테이블보기를 보여주는 것을 내가 같은 테이블의 다른 열을 표시하는 사용자 정의 셀을 사용하고있는 동안 문제였다 같이 나도 같은보기를 원하는
을 위와 같이 검색하는 동안 또는 검색 후 나는이보기를 얻을 동안 검색 를 완료 한 후tablevi의 차이를보기 검색 헤더가 사라지면 ews가 표시됩니다. 누군가가 디스플레이 컨트롤러가없는 경우에만 세이코 바를 사용하도록 제안했습니다. 나는 내 응용 프로그램에서 검색보기 컨트롤러 사용하고이 문제
NSLog 배열의 filteredListitems을. – Hiren
이 선택되어 있으면 검색 버튼이 작동하지 않고 filteredListItems 배열이 listVehicles의 모든 항목을 표시합니다. –
검색 막대를보기에 추가하는 방법은 무엇입니까? – Hiren