У меня была странная проблема с ячейками таблицы, которую я никогда раньше не видел. Они кровоточат, когда я прокручиваю стол. Например, сейчас у меня есть ячейка в первом разделе с надписью «Устройство» и группа ячеек во втором разделе с надписью «Привет», а затем несколько пустых ячеек в третьем разделе. Когда я прокручиваю, иногда «Устройство» пишется поверх «Привет» (поэтому обе метки видны, но накладываются друг на друга (они имеют четкий цвет фона), а иногда «Привет» пишется в ячейках третьего раздела. пытаясь понять, что не так, но ничего не получается.
Вот соответствующие разделы моего контроллера табличного представления:
- (id)initWithDeviceCoordinator:(DeviceCoordinator*)dev_con
{
self = [super initWithStyle:UITableViewStyleGrouped];
if (self) {
device_coordinator = dev_con;
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
if (section == 0 || section == 3) return 1;
else if (section == 1) return 8;
else if (section == 2) return 2;
}
- (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] autorelease];
}
if (indexPath.section == 0) cell.textLabel.text = [device_coordinator getDeviceName];
else if (indexPath.section == 1)
{
if (indexPath.row == [[device_coordinator getChannelList] count])
{
cell.textLabel.text = @"Add new channel";
return cell;
}
cell.textLabel.text = @"HI";
return cell;
}
return cell;
}
Все остальные функции в классе по умолчанию являются XCode.