UIView 애니메이션을 사용하여 UITableViewCell 높이를 변경하는 애니메이션을 만들고 싶습니다 (앞으로 봄 애니메이션 사용).UITableViewCell의 높이를 변경하기위한 사용자 정의 애니메이션
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.backgroundColor = [UIColor greenColor];
}
UILabel *viewLabel = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, 10.0f, [[UIScreen mainScreen] bounds].size.width, 40.0f)];
viewLabel.text = @"Test";
viewLabel.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:viewLabel];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView beginUpdates];
[self animateCell:indexPath andTableView:tableView];
[tableView endUpdates];
}
- (void)animateCell:(NSIndexPath*)indexPath andTableView:(UITableView*)tableView
{
[UIView animateWithDuration:1.0f animations:^
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
CGRect rect = cell.frame;
rect.size.height = 90.0f;
cell.frame = rect;
NSLog(@"%f", cell.frame.size.height);
}];
}
을하지만 그것은 작동하지 않습니다
그래서 내가있다. 하지만 난`는 추가하는 경우 :- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([indexPath isEqual:[tableView indexPathForSelectedRow]])
{
return 90.0f;
}
return 40.0f;
}
내가 셀 animateCell 방법에서 생성되는 사용자 정의 셀에 적용되는 높이와 애니메이션을 변경하는 것을 볼
는, jQuery과 기본 애니메이션을 수행 여기
tableView:didSelectRowAtIndexPath:
선택한 셀의 최종 상태에서 애니메이션의 예입니다. 애니메이션 속성은 테이블 뷰의 데이터 소스 값을 기반으로합니다. – vokilam
그래서 beginUpdates와 endUpdates를 호출 할 필요가 없으며 맞춤 애니메이션 (셀 근처의 위치를 애니메이션으로 변경)을 처리 할 필요가 없습니까? – Dimitrio
애니메이션은 무엇이되어야합니까? – vokilam