0

UITableView各行に名前と各名前の画像を含む があります。特定の名前が検索されると、画像は同じもので検索されませんUITableViewCell。最初の行またはセルのイメージは変わりません。画像も検索するにはどうすればよいですか?

検索問題の画像をアップロードしました。

[1]: http://i.stack.imgur.com/QcvtU.png "TableView"

[2]: http://i.stack.imgur.com/RmsIv.png "テーブルビューで検索"

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) 
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier ];
} 
if(temp==1)
{
    cell.textLabel.text = [newarray objectAtIndex:indexPath.row];
    //cell.textLabel.text = [newarray2 objectAtIndex:indexPath.row];
}
else
{     
    cell.textLabel.text= [array objectAtIndex:indexPath.row];
    cell.imageView.image = [UIImage imageNamed:[imagearray objectAtIndex:indexPath.row]];
}
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
return cell;
}
4

1 に答える 1

0

name 項目に対して変更可能な newarray がある場合は、newarrayimages も作成する必要があります。したがって、newarray のような newarrayimages を割り当てて初期化し、以下を追加します。

if(temp==1)
{
    cell.textLabel.text = [newarray objectAtIndex:indexPath.row];

    //line to add
    cell.imageView.image = [UIImage imageNamed:[newarrayimages objectAtIndex:indexPath.row]];

}

これを試して、私に知らせてください。に

于 2012-06-19T09:26:53.317 に答える