我有ipad中有tableView顯示內容,我希望當用戶在搜索文本框中輸入任何數據時,匹配記錄應該顯示在tableView中。如何從tableView中使用textfield搜索ipad中的數據
- (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
ABCArray是陣列,其中它將搜索示出表中的數據平均排列 –
是,ABCArray是其在numberofRowsInTableView方法,使用的陣列。 – Tendulkar
爲什麼我們使用firstLetter爲空 –