Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.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 tableviewcell高光图像的缓慢加载_Iphone_Objective C_Uitableview_Colors_Highlight - Fatal编程技术网

Iphone tableviewcell高光图像的缓慢加载

Iphone tableviewcell高光图像的缓慢加载,iphone,objective-c,uitableview,colors,highlight,Iphone,Objective C,Uitableview,Colors,Highlight,我有一个表格,里面充满了tableviewcells,它们的高亮颜色是imageview 有时候,当我点击一个单元格时,imageview的加载有点滞后。我想知道如何减少滞后 我有以下资料: cell.selectedBackgroundView = [DataSingleton sharedMySingleton].highlightView; 方法内部: -(void) tableView:(UITableView *)tableView willDisplayCell:(UITableV

我有一个表格,里面充满了tableviewcells,它们的高亮颜色是imageview

有时候,当我点击一个单元格时,imageview的加载有点滞后。我想知道如何减少滞后

我有以下资料:

cell.selectedBackgroundView = [DataSingleton sharedMySingleton].highlightView;
方法内部:

-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
注意:我每次点击它都会给它打电话。我将尝试在本地设置图像,看看这是否会有所不同


编辑:所以我在viewDidLoad中本地设置了imageview,它的反应似乎快多了。我想我的问题是单例,但我希望能够一次更改所有突出显示的图像。是否有一种方法可以快速加载全局变量?

我不太确定,但下面可能会有助于提高性能

而不是用willDisplayCell方法编写代码。您可以使用cellForRowIndexPath方法编写

像这样的

static NSString *CellIdentifier = [NSString stringWithFormat:@"MyIdentifier%d",indexpath.row];

UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

 cell.selectedBackgroundView = [DataSingleton sharedMySingleton].highlightView;
}
当您为该单元分配内存时,idea仅设置一次selectedbackgroundView。您需要为此使用reuseidentifier


希望这能帮上忙。

嘿,我有另一个相关问题,但我不想再提另一个问题,我想知道你是否能帮上忙。我将高光设置为保持选中状态,但当我转到另一个视图并单击其中一个TableViewCell,然后返回到原始视图时,高光IMAGEVIEW消失了,但高光文本颜色仍然存在,这意味着它知道它仍然高亮显示,但IMAGEVIEW没有保留。有什么建议吗?