【发布时间】:2014-01-09 11:01:54
【问题描述】:
如何使用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;
}
【问题讨论】:
-
您的意思是,当您在搜索栏中输入文本时。它应该在 tableview 中填充数据吧??
-
如何在没有数组的情况下搜索 cell.textlabel.text 值..
-
我的意思是,你想在搜索栏中传递这个 cell.textlabel.text 值吗??
-
是的。必须传递值。然后才能搜索它..
-
我的意思是 UISearchbar 在 UITableView 之外?不在 UITableView 内。是这样的吗??
标签: ios objective-c uitableview uitextfield