ios - расширить ячейку табличного представления, как приложение Twitter
Я хочу, чтобы при выборе твита было то же поведение, что и в приложении Twitter: расширение строки и добавление дополнительного контента.
Так что это не только основной размер строки. Я думаю, что мне нужно 2 разных пользовательских ячейки, поэтому я сделал что-то вроде этого:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([indexPath compare:self.selectedIndexPath] != NSOrderedSame) {
FirstCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FirstCell"];
if (!cell) {
cell = [[FirstCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"FirstCell"];
}
cell.firstnameLabel.text = [[self.items objectAtIndex:indexPath.row] objectForKey:@"firstname"];
return cell;
}
else {
SecondCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SecondCell"];
if (!cell) {
cell = [[SecondCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SecondCell"];
}
cell.firstnameLabel.text = [[self.items objectAtIndex:indexPath.row] objectForKey:@"firstname"];
cell.lastnameLabel.text = [[self.items objectAtIndex:indexPath.row] objectForKey:@"lastname"];
return cell;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([indexPath compare:self.selectedIndexPath] == NSOrderedSame) {
return 80.0;
} else {
return 44.0;
}
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.selectedIndexPath = indexPath;
[tableView reloadData];
}
Моя проблема здесь в том, что я хочу сохранить плавную анимацию, такую как приложение Twitter, что не в моем случае из-за[tableView reloadData]
(что является обязательным, я думаю, так как у меня есть 2 различных пользовательских ячейки).
Итак, кто-нибудь знает, как мне обойтись, или, может быть, кто-то знает, как приложение Twitter обрабатывает эту анимацию?