Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.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
Iphone 如何突出显示UITableViewCell_Iphone - Fatal编程技术网

Iphone 如何突出显示UITableViewCell

Iphone 如何突出显示UITableViewCell,iphone,Iphone,我非常想临时突出显示一个UITableViewCell,以提请大家注意包含的数据已经更改的事实 有一个UITableViewCell方法:-setHighlighted:(BOOL)animated:(BOOL)但我不能让它做任何事情 以下是视图控制器的相关部分: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableVie

我非常想临时突出显示一个UITableViewCell,以提请大家注意包含的数据已经更改的事实

有一个UITableViewCell方法:-setHighlighted:(BOOL)animated:(BOOL)但我不能让它做任何事情

以下是视图控制器的相关部分:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  UITableViewCell *cell;
  switch (indexPath.section) {
    case 0: {
     if (indexPath.row == 0) {
    cell = [[UITableViewCell alloc ] initWithStyle:UITableViewCellStyleDefault 
                                   reuseIdentifier:@"currentLoc"];
    cell.accessoryType = UITableViewCellAccessoryNone;
      cell.textLabel.text = @"This is the special cell";
    }
    [cell setHighlighted:YES animated:YES];
    [cell setHighlighted:NO animated:YES];

    //[cell setNeedsDisplay];

  } else {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                   reuseIdentifier:@"setLocAutomatically"];
    cell.accessoryType = UITableViewCellAccessoryNone;
    cell.textLabel.text = @"Foo";

  }
} break;
case 1: {
  cell = [[UITableViewCell alloc ] initWithStyle:UITableViewCellStyleDefault
                                 reuseIdentifier:@"selectCity"];
  cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  if (indexPath.row == 0) {
    cell.textLabel.text = @"Select a Bar";
  } else {
    cell.textLabel.text = @"Select a Baz";
  }
} break;
  }
  [cell autorelease];
  return cell;
}
请参阅上面的[cell setHighlight…]了解我的尝试

令我非常沮丧的是,手机没有突出显示,我也没有找到任何方法让它工作

谢谢,


Carl C-M

因为您在
表格视图:cellForRowAtIndexPath:
中执行所有这些操作,所以在返回单元格后,屏幕上的单元格才会发生任何变化。因此,将单元格设置为高亮显示不会对用户可见


您要做的是找到一种方法,在从方法返回单元格后将其设置为高亮显示。也许研究一下这个方法可能会对您有所帮助—您可以将单元格设置为带延迟的高亮显示,这样它就会返回、显示,然后高亮显示。

因为您在
表视图:cellForRowAtIndexPath:
中执行所有这些操作,所以在返回单元格后,屏幕上的单元格不会发生任何变化。因此,将单元格设置为高亮显示不会对用户可见


您要做的是找到一种方法,在从方法返回单元格后将其设置为高亮显示。也许研究一下这个方法会对您有所帮助—您可以将单元格设置为延迟高亮显示,这样它就会返回、显示,然后高亮显示。

您是否想过更改单元格的UILabel并简单地更改外观,而不是尝试更改单元格本身。可能是不同的文本颜色或粗体

这将允许您将更改保存在
tableView:cellforrowatinexpath:

这还可以确保突出显示的默认外观不会与更改信息的附加消息混合在一起。突出显示可能意味着很多事情,但是文本格式可以用来表示您的特定概念

UILabel * textLabel = [yourCell textLabel];
// From here you can alter the text

您是否想过更改单元格的UILabel,只需更改外观,而不是尝试更改单元格本身。可能是不同的文本颜色或粗体

这将允许您将更改保存在
tableView:cellforrowatinexpath:

这还可以确保突出显示的默认外观不会与更改信息的附加消息混合在一起。突出显示可能意味着很多事情,但是文本格式可以用来表示您的特定概念

UILabel * textLabel = [yourCell textLabel];
// From here you can alter the text

尝试使用
[tblView SelectRowatineXpath:myIndex动画:是scrollPosition:UITableViewScrollPositionTop]
功能

尝试使用
[tblView SelectRowatineXpath:myIndex动画:是scrollPosition:UITableViewScrollPositionTop]

功能

只需将突出显示/背景更改/任何代码放入:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

只需将突出显示/背景更改/任何代码放入:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

我在这方面有一个变化,它继续困扰着我。我有一个向导,它使用表格来指示可能的选择。选择完成后,我想暂时高亮显示所选行,然后前进到向导中的下一帧

我在公司做高级职员

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
但我不能让精彩发生


有什么建议吗?

我在这方面有一个变化,这一直困扰着我。我有一个向导,它使用表格来指示可能的选择。选择完成后,我想暂时高亮显示所选行,然后前进到向导中的下一帧

我在公司做高级职员

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
但我不能让精彩发生

有什么建议吗?

试试这个:

[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
试试这个:

[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
在uitableviewdelegate中使用此选项,然后当您要高亮显示单元格标记时,请在tableview上调用reloadData


在uitableviewdelegate中使用此选项,然后当您要突出显示单元格标记时,单元格将在tableview上调用reloadData

我最终使用了Tim建议的一个变体performSelector:withObject:afterDelay:。我高亮显示单元格,然后在稍微延迟后进入向导中的下一帧。显示选择就足够了,这就是我所需要的。我最后使用了Tim建议的performSelector:withObject:afterDelay:的变体。我高亮显示单元格,然后在稍微延迟后进入向导中的下一帧。这足以显示选择,这就是我所需要的。