UITable重叠,表不';t在iPhone中重新加载
UITable会重叠,当我尝试重新加载它时,它不会动态更新自身。。我使用表重载来重新加载,但仍然没有得到解决方案。UITable重叠,表不';t在iPhone中重新加载,iphone,objective-c,xcode,uitableview,Iphone,Objective C,Xcode,Uitableview,UITable会重叠,当我尝试重新加载它时,它不会动态更新自身。。我使用表重载来重新加载,但仍然没有得到解决方案。 提前感谢。我认为问题在于您的单元格内容大于单元格高度 实现UITableView的heightForRowAtIndexPath方法 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString
提前感谢。我认为问题在于您的单元格内容大于单元格高度 实现UITableView的
heightForRowAtIndexPath
方法
- (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];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
if(tableView==logTable)
{
lbl_description=[[UILabel alloc] init];
[cell.contentView addSubview:lbl_description];
lbl_description.backgroundColor = [UIColor clearColor];
lbl_description.textColor=[UIColor darkGrayColor];
lbl_description.font = [UIFont systemFontOfSize:18];
lbl_date=[[UILabel alloc] init];
[cell.contentView addSubview:lbl_date];
lbl_date.backgroundColor = [UIColor clearColor];
lbl_date.textColor=[UIColor lightGrayColor];
lbl_date.font = [UIFont systemFontOfSize:14];
lbl_description.frame=CGRectMake(10, 3, 300, 25);
lbl_date.frame=CGRectMake(10, 23, 300, 25);//left
lbl_description.text = [getName objectAtIndex:indexPath.row];
lbl_date.text=[getStartDate objectAtIndex:indexPath.row];
}
return cell;
}
删除
cell==nil
循环,不会发生重叠。尝试在cell=nil的if循环中分配lbl\u日期和描述标签,并将其添加到cell content在相同的if循环中查看。仅向if cell==nil循环外部的标签添加文本;当前所做的是在每次调用委托方法时分配和添加标签
- (CGFloat)tableView:(UITableView *)tv heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 70.0f;
}