【发布时间】:2012-10-05 11:16:25
【问题描述】:
在我的应用程序中,我使用四个 UITextView 自定义了 UITableView 单元。每当我将数据添加到 tableview 并重新加载它时。 UITableViewCell 中的文本会被之前的文本覆盖。
我尝试了不同的方法,但无法找出问题所在。
我在 View Controller 中使用 TableView。
这是我在表格视图单元格中使用的代码?
if ( [tableView isEqual:self.tableActions])
{
//Setting the text empty
static NSString *CellIdentifier = @"ActionsIdentifier";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
NSLog(@"Index Path %i",[indexPath row]);
ActionDetails *actiondetails = [actionArray objectAtIndex:[indexPath row]];
NSLog(@"Action Text %@",actiondetails.actions);
//Actions
actionText=[[UITextView alloc] initWithFrame:CGRectMake(10, 5, 230,30)];
actionText.font = [UIFont systemFontOfSize:17.0];
actionText.editable = NO;
actionText.textColor=[UIColor blackColor];
actionText.text = actiondetails.actions ;
actionText.userInteractionEnabled = NO;
actionText.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:actionText];
//Owner
ownerBy=[[UITextView alloc] initWithFrame:CGRectMake(230, 5, 230,30)];
ownerBy.font = [UIFont systemFontOfSize:17.0];
ownerBy.textColor=[UIColor blackColor];
ownerBy.textAlignment = UITextAlignmentCenter;
ownerBy.text = actiondetails.owner;
ownerBy.editable = NO;
ownerBy.userInteractionEnabled = NO;
ownerBy.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:ownerBy];
}
屏幕截图
感谢你们的帮助。
非常感谢。
【问题讨论】:
-
感谢您的回答,伙计们 +1 对您的所有支持..
-
你得到这个解决方案了吗?我也有同样的问题
标签: iphone ios uitableview