У меня есть reusableCell, у которого есть метка, для которой значения предоставляются массивом. Но значения метки и ограничений меняются каждый раз, мой код cellForRowAtIndexPath выглядит так:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row % 2 == 0)
{
isReceived =TRUE;
}
else{
isReceived = FALSE;
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"id" forIndexPath:indexPath];
ChatMessageCellTableViewCell *messageCell = (ChatMessageCellTableViewCell*) cell;
if(messageCell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ChatMessageCellTableViewCell" owner:self options:nil];
messageCell = [nib objectAtIndex:0];
}
else{
[[messageCell formLabel]setText:messages[indexPath.row]];
[messageCell setSelectionStyle:UITableViewCellSelectionStyleNone];
} // this else part is just to make sure that the if has a else part as I saw many people it will work , but in my case it didn't help.
[[self tableView] setEstimatedRowHeight:50.0];
[self.tableView setRowHeight:UITableViewAutomaticDimension];
return messageCell;
}
Когда я прокручиваю таблицу, значения меняются. Я пытался по-разному, но не смог найти решение, и я так растерялся, что мне пришлось опубликовать свой вопрос.
Спасибо