Я добавляю границу к UITableViewCell. Ниже приведен код:Как решить проблему перекрытия границы в UITableViewCell?
Try-1:
cell.layer.borderWidth = 1;
cell.layer.borderColor = [UIColor redColor].CGColor;
Try-2:
cell.contentView.layer.borderWidth = 1;
cell.contentView.layer.borderColor = [UIColor redColor].CGColor;
Я попробовал оба эти пути, вот выход.
Как вы можете найти на изображении, граница перекрывается между двумя ячейками, поскольку этот цвет становится темнее, чем пограничные ячейки.
Почему я не добавил границу стола?
- Проблема в том, я использую три Diff пользовательских ячеек в одной таблице, в соответствии с данными, особенно ячейка загружается
- Поэтому я не могу добавить цвет границы для всей UITableView или не в состоянии сделать границы ячеек в cellforrowatindexpath. Потому что в этом методе только я проверяю, какой тип данных он есть, и соответственно пользовательская ячейка была загружена.
Вот мой cellForRowAtIndexPath
:
- (UITableViewCell*) getTableViewCellForTraining:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath withTrainingInfo:(TrainingInfoiOS*)trainingInfo
{
BeLearnPlatform& ptr = BeLearnPlatform::GetLearnPlatform();
static NSString *CustomCellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier forIndexPath:indexPath];
cell.courseNameLabel.text = trainingInfo.courseName;
cell.courseStartButton.sectionID = indexPath.section;
cell.courseStartButton.rowID = indexPath.row;
cell.tag=0;
...
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* cell = nil;
NSString* dictionaryKey = [self createKeyWithSection:indexPath.section andRow:indexPath.row];
NSObject* dataObject = [tableViewMappig objectForKey:dictionaryKey];
if([dataObject isKindOfClass:[MasterCourse class]])
{
UITableViewCell* cell = [self getTableViewCellForTraining:tableView cellForRowAtIndexPath:indexPath withTrainingInfo:(MasterCourse*)dataObject];
return cell;
}
else if([dataObject isKindOfClass:[ParentCourse class]])
{
UITableViewCell* cell = [self getTableViewCellForParentCourse:tableView cellForRowAtIndexPath:indexPath withTrainingInfo:(ParentCourse*)dataObject];
return cell;
}
Пожалуйста, предложите мне решение для этого.
Добавить разделитель в tableViewCell и добавить пограничный слой в таблицуView – Dilip
Я не могу этого сделать. Есть несколько ячеек, которые имеют разную компоновку, чем это. Это пограничные ячейки. Таким образом, я не могу добавить разделительную линию ко всему представлению таблицы. – Mrunal