相关疑难解决方法(0)

在滚动时复制UITableViewCell contentView的子视图(UIButton和UIImageView)

在我的tableView中,在一些单元格中,我添加了一个imageView作为单元格contentView的子视图.在滚动表上查看上下这些图像也复制在其他单元格上.但这个问题并不总是发生.请提出解决方案..我正在使用以下代码.

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) 
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];

    if (friendsArray.count != 0)
    {
        NSString *str = [friendsIdArray objectAtIndex:indexPath.row];
        if ([pendingRequests containsObject:str])
        {
            // Add image for pending item
            UIImageView *pendImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pendng.png"]];
            pendImage.frame = CGRectMake(220.0, 2.5, 70, 40);
            pendImage.tag = indexPath.row;   
            [cell.contentView addSubview:pendImage];
        }
    }

}

NSString *object;

if (friendsArray.count == 0)
{
    if ([cell.contentView viewWithTag:indexPath.row]) 
    {
        for (UIView *subview in …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c uitableview

3
推荐指数
1
解决办法
1195
查看次数

标签 统计

objective-c ×1

uitableview ×1

xcode ×1