Ios 如何使用此代码在tableview中使用搜索栏?
如何使用Ios 如何使用此代码在tableview中使用搜索栏?,ios,objective-c,uitableview,uitextfield,Ios,Objective C,Uitableview,Uitextfield,如何使用textfield搜索cell.textlab.text值?我正在使用这个代码 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefa
textfield
搜索cell.textlab.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中。是这样吗??