问:自定义TableViewCell滚动到无法看到,并再次显示我的自定义行关闭

时间:2016-08-11 02:56:10

标签: ios objective-c uitableview

我的custom cell中有两个不同的tableview,在第一个单元格中,我在系统单元格行下面添加了一个自定义单元格行:

_bottom_line = [[UIView alloc] initWithFrame:CGRectMake(0, 49, kScreen_Width, 1)];
_bottom_line.backgroundColor = Back_Color_QQ;
[part3 addSubview:_bottom_line];

controller设置我的自定义单元格;

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.section == 0) {  // my first cell

        static NSString *id_cell1 = @"cell1";
        AgDetailTechCell *cell = [tableView dequeueReusableCellWithIdentifier:id_cell1];
        if (cell == nil) {
            cell = [[AgDetailTechCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:id_cell1];
        }

        ((AgDetailTechCell *)cell).model = self.headerModel;
        ((AgDetailTechCell *)cell).indexPath = indexPath;
        ((AgDetailTechCell *)cell).delegate = self;
        _head_cell = cell;

        _head_cell.comemntCountlabel.text = self.headerModel.lml_commentTimes;
        _head_cell.likeCountlabel.text = self.headerModel.lml_likeTimes;

        return cell;
    }else {  // other cells

        static NSString *id_cell2 = @"cell2";
        AgPreOrHelpCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:id_cell2];
        if (cell == nil) {
            //cell = [[AgPreOrHelpCommentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:id_cell2];
            cell = [[NSBundle mainBundle] loadNibNamed:@"AgPreOrHelpCommentCell" owner:self options:nil].firstObject;
        }
        cell.delegate = self;
        cell.indexPath = indexPath;
        [cell initCellDataWithModel:self.dataSource[indexPath.row]];


        cell.refresh = ^(UITableViewCell *currentCell) {


            [self.tableView reloadData];

             [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];

        };


        return cell;
    }

}

第一次进入控制器时,显示效果很好。但是在我滚动tableview以隐藏并再次显示之后,我的自定义底线被忽略,我找不到它。我刷新了我的tableView,再次显示自定义行。我有令牌2图片来解释更多细节:

First time into the controller it shows well After scroll my tableview and show the line ,it dismss

更新 使用苛刻的建议,但问题没有变化:

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

    if ([cell.reuseIdentifier isEqualToString:@"cell1"]) {
        // customs bottom_line
         UIView * bottom_line = [[UIView alloc] initWithFrame:CGRectMake(0, 49, kScreen_Width, 1)];
        bottom_line.backgroundColor = Back_Color_QQ;

        [((AgDetailTechCell *)cell).part3 addSubview:bottom_line];
    }

}

2 个答案:

答案 0 :(得分:1)

如果你的灵魂目的是从头到尾扩展默认分隔符。

查看此帖子How to fix UITableView separator on iOS 7?

答案 1 :(得分:0)

也许你的底线不在你的牢房里。确保为细胞返回50或更高的高度。另一件事是禁用UITableView的系统底线。

相关问题