[英]How to use search bar in tableview using this code?
如何使用textfield
搜索cell.textLabel.text
值? 我正在使用此代碼。
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UITextField* tf = nil ;
switch ( indexPath.row ) {
case 0: {
cell.textLabel.text = @"Name" ;
tf = nameField_ = [self makeTextField:self.name placeholder:@"sathish"];
[cell addSubview:nameField_];
break ;
}
case 1: {
cell.textLabel.text = @"Address" ;
tf = addressField_ = [self makeTextField:self.address placeholder:@"example@gmail.com"];
[cell addSubview:addressField_];
break ;
}
case 2: {
cell.textLabel.text = @"Password" ;
tf = passwordField_ = [self makeTextField:self.password placeholder:@"Required"];
[cell addSubview:passwordField_];
break ;
}
case 3: {
cell.textLabel.text = @"Description" ;
tf = descriptionField_ = [self makeTextField:self.description placeholder:@"My Gmail Account"];
[cell addSubview:descriptionField_];
break ;
}
}
tf.frame = CGRectMake(120, 12, 170, 30);
[tf addTarget:self action:@selector(textFieldFinished:) forControlEvents:UIControlEventEditingDidEndOnExit];
tf.delegate = self ;
return cell;
}
基本步驟:
這個流行的鏈接,你有更多的主意
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.