gpt4 book ai didi

ios - Q : Custom TableViewCell scroll to not see, 并再次显示,我的自定义行关闭

转载 作者:行者123 更新时间:2023-11-29 00:43:51 24 4
gpt4 key购买 nike

我的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;
}

}

第一次进入controller,显示不错。但是当我滚动我的 tableview 来隐藏并再次显示时,我的自定义底线消失,我找不到它。当我刷新我的 tableView 时,自定义线再次出现。我有 token 2 图片来解释更多细节:

更新使用 Harsh 的建议,但问题没有改变:

- (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];
}

}

最佳答案

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

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

关于ios - Q : Custom TableViewCell scroll to not see, 并再次显示,我的自定义行关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38886534/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com