我有 ipad,它有 tableView 显示内容,我希望当用户在搜索文本字段中输入任何数据时,匹配的记录应该显示在 tableView 中。
- (void)onSearchButtonClick
{
if (searchTextField.text == nil || searchTextField.text.length == 0) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"You must fill the text to search first!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
return;
}
[searchTextField resignFirstResponder];
}
这是 tableView 中通常显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CustomCellIdentifier = @"CustomCellIdentifier";
CustomCell *cell = (CustomCell *)[tableView
d equeueReusableCellWithIdentifier: CustomCellIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell"
owner:self options:nil];
for(id oneObject in nib)
if ([oneObject isKindOfClass:[CustomCell class]])
cell = (CustomCell *)oneObject;
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
appDelegate = (MultipleDetailViewsWithNavigatorAppDelegate *)[[UIApplication sharedApplication] delegate];
ObjectData*obj;
obj=[appDelegate.detailArray objectAtIndex:indexPath.row];
type=obj.contentType;
content_Type=obj.contentType;
content_Source=obj.contentSource;
cell.text=Content_Source;
return cell;
}
我希望当点击搜索时它应该匹配记录并显示在 tableView