0
我添加了一個UILabel作爲我的tableview的內容視圖。 UILabel中的文本在滾動時重疊。以下是代碼。UITableViewCell - 滾動時ContentView重疊
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.chatTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Group"];
static NSString *CellIdentifier = @"Group";
UITableViewCell *cell = [self.chatTableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = self.latestTrimText;
UILabel *cellLabel = [[UILabel alloc]init];
cellLabel.text = self.dateOfLatestTrim;
cellLabel.frame = CGRectMake(15, 0, 150, 30);
[cell.contentView addSubview:cellLabel];
return cell;
}
我可以通過改變UITableViewCell *cell = [self.chatTableView dequeueReusableCellWithIdentifier:nil];
但後來解決這個問題,實現代碼如下的滾動不會一帆風順。是否有另一種方法來解決這個問題?