Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何使用此代码在tableview中使用搜索栏?_Ios_Objective C_Uitableview_Uitextfield - Fatal编程技术网

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;
}
基本步骤:

  • 在类中声明并初始化UISearchBar
  • 声明并初始化UISearchDisplayController
  • 将搜索栏添加到表格视图中
  • 实现UISearchDisplayController委托方法
  • 这个流行的链接让你有更多的想法


    您的意思是,当您在搜索栏中输入文本时。它应该填充tableview右侧的数据??如何搜索cell.textlabel.text值而不使用数组..我的问题是,是否要在搜索栏中传递此cell.textlabel.text值?是的。必须传递值。然后才能搜索..我的意思是UISearchbar在UITableView之外?不在UITableView中。是这样吗??