数据已经绑定上去了,运行时正常,但在点击表格内容时,格子里显示的内容消失
点击之前
点击之后
黄舟2017-04-18 09:36:50
This means that the cell size is not well controlled. Detached from actual size. What you have to do now is to re-set the frame when cell setdata. That way there's no problem.
阿神2017-04-18 09:36:50
I agree with @yangfanace’s idea.
I don’t know how your subview is created and added to the cell, but when you click, the system will have a default click effect, which is gray.
The default click effect of this system covers the subviews on the cell. So...
PHP中文网2017-04-18 09:36:50
In the cellForRowAtIndexPath method, when displaying custom cell content based on row, try the return cell at the end of the if statement content
高洛峰2017-04-18 09:36:50
@yangfanace Try setting Cell’s selectionStyle to none
Perfectly solved my problem, thank you
伊谢尔伦2017-04-18 09:36:50
Give return cell after each judgment.
-(UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell){
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if(resultsArr.count == 0){
cell.textLabel.text = @"暂无数据";
cell.userInteractionEnabled = NO;
cell.textLabel.font = [UIFont systemFontOfSize:14];
return cell;
}else{
HouseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HouseTableViewCell" forIndexPath:indexPath];
jingpingModel *tuijianmodel = [[jingpingModel alloc] initWithDic:resultsArr[indexPath.row]];
IDarr[indexPath.row] = tuijianmodel.ID;
NSLog(@"IDARR IS %@",IDarr);
NSURL *picurl = [NSURL URLWithString:tuijianmodel.iconImage];
[cell.iconImageview sd_setImageWithURL:picurl];
cell.townnameLabel.text = tuijianmodel.area;
cell.xiaoquName.text = tuijianmodel.name;
cell.huxingLabel.text = tuijianmodel.houseType;
cell.mianjiLabel.text = tuijianmodel.sqm;
cell.shoujiaLabel.text = tuijianmodel.totalPrice;
cell.isJishouLabel.text = tuijianmodel.status;
cell.posttimeLabel.text = tuijianmodel.posttime;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
return cell;
}
迷茫2017-04-18 09:36:50
It’s not a matter of selecting the style, because the selected style won’t even cover the things inside the cell.