2012-06-02 5 views
0

tableview의 각 셀에 애니메이션을 설정하고 싶습니다. 따라서 테이블의 셀을 선택하면 셀만 비례하여 flipOver 애니메이션처럼 보입니다.개별 UITableViewCell에 어떻게 애니메이션을 적용합니까?

일부 코드가 있습니다. 하지만 내가 선택한 경우 모든 테이블이 플립됩니다. 뿐만 아니라 세포.

코드는 다음과 같습니다.

-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath 
{ 
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
    [tableView deselectRowAtIndexPath:indexPath : YES ]; 
    [UIView transitionFromView:cell toView:checkProjectView duration:1.0f options:UIViewAnimationOptionTransitionFlipFromLeft completion:NULL]; 
    [UIView commitAnimations]; 
} 

어떻게 구현할 수 있습니까?

그리고이 샘플에서 2 조회 있습니다. 도와주세요.

답변

0

시도해 볼 수있는 대안이 하나 있습니다. 셀을 만드는 동안 UIView 객체를 만듭니다. 이보기의 모양은 셀의 모양과 비슷해야합니다. 이제 Cell의 contentview를 해당 뷰로 설정하십시오.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    // See if there's an existing cell we can reuse 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Foobar"]; 
    if (cell == nil) { 
     // No cell to reuse => create a new one 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Foobar"] autorelease]; 

    } 

    // Customize cell 
    [cell.contentView addSubview:customView]; // customView is your view which you want to set 

    return cell; 
} 

이제이 CustomView에 애니메이션 코드를 사용하십시오.

-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath 
{ 
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
    [tableView deselectRowAtIndexPath:indexPath : YES ]; 
    [UIView transitionFromView:[cell.contentView viewWithTag:#tagof view here] toView:checkProjectView duration:1.0f options:UIViewAnimationOptionTransitionFlipFromLeft completion:NULL]; 
    [UIView commitAnimations]; 
} 
관련 문제