Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.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自定义单元格上textfield文本的高亮显示颜色_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 更改tableview自定义单元格上textfield文本的高亮显示颜色

Ios 更改tableview自定义单元格上textfield文本的高亮显示颜色,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我有一个带有自定义单元格的tableview。自定义单元格上有文本字段 当单元格高亮显示时,我想将文本字段的文本颜色从白色更改为黑色 我知道cell.textlab.highlightedTextColor,但是有人能想出一种方法来改变它作为一个textfield吗 谢谢。您可以实施委托协议方法(可从iOS 6.0获得)tableView:shouldHighlightRowatineXpath:或tableView:DidHighlightRowatineXpath:,具体取决于您的要求,要拦

我有一个带有自定义单元格的tableview。自定义单元格上有文本字段

当单元格高亮显示时,我想将文本字段的文本颜色从白色更改为黑色

我知道cell.textlab.highlightedTextColor,但是有人能想出一种方法来改变它作为一个textfield吗


谢谢。

您可以实施委托协议方法(可从iOS 6.0获得)tableView:shouldHighlightRowatineXpath:tableView:DidHighlightRowatineXpath:,具体取决于您的要求,要拦截用户,请触摸并从中获取指向感兴趣的UITextField的指针

以下内容假定位于一个对象内部,该对象既是表视图委托又是数据源

- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
     // get the cell by calling datasource protocol method
     UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
     // fast enumeration to get UITextField(s) from the cell
     for (UITextField *textField in cell.subviews) {
          // change color here...
          textField.textColor = [UIColor redColor];
          }
     return YES;
}