2013-09-06 1 views
2

splitviewController의 첫 번째 viewController에있는 표의 경우 깜박이는 애니메이션을 tableViewcellcontentView에 적용했습니다. 내 문제는 내가있는 UITableViewCell 하위 클래스했다 splitViewController분할 뷰 컨트롤러의 마스터가 숨겨지면 코어 애니메이션이 중지됩니다 (세로 모드에서)?

presentsWithGesture 특성으로 FirstViewcontroller을 숨기고 속성과 을 설정하는 동안 나는 내가 좋아하는 cellcontentView에 애니메이션을 추가 애니메이션을 추가 할 때 애니메이션이 중지입니다

-(void)setProperty:(Property *)aProperty 
{ 
    _property=aProperty; 
    [self.contentView addSubview:self.dateLabel]; 
    self.dateLabel.text=[self.meeting stringforScheduleDate]; 
    if (_property.opened) { 
     CABasicAnimation *theAnimation; 
     CALayer *layer=[self.contentView layer]; 
     theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"]; 
     theAnimation.duration = 0.5; 
     theAnimation.delegate=self; 
     theAnimation.fromValue = [NSNumber numberWithFloat:0.0]; 
     theAnimation.toValue = [NSNumber numberWithFloat:1.0]; 
     theAnimation.repeatCount=HUGE_VALF; 
     theAnimation.autoreverses=YES; 
//  [layer removeAnimationForKey:@"opacity"]; 
     [layer addAnimation:theAnimation forKey:@"opacity"]; 
    } 
    else 
    { 
     CALayer *layer=[self.contentView layer]; 
     [layer removeAnimationForKey:@"opacity"]; 
    } 
} 

아래

보이지 않을 때 뷰 계층 구조에서 핵심 애니메이션을 멈추는 ViewController의 동작인지 또는 내 코드에서 무언가를 놓쳤는지를 알지 못합니다. 그래서 동료들 도와주세요

+1

안녕하세요 Vignesh, 솔루션을 찾고 계십니까? – doNotCheckMyBlog

+0

@doNotCheckMyBlog 예, 일시적으로 viewDidAppear에서 tableView를 다시로드하여 애니메이션이 아직있는 것처럼 보이게합니다. –

+0

uitableviewcell의 [CABasicAnimation] 중 가능한 중복이 작동하지 않는 것 같습니다. (http://stackoverflow.com/questions/26941027/cabasicanimation-in-uitableviewcell-doesnt-seem-to-work) – Fattie

답변

5

예, 뷰 컨트롤러가 숨겨지면 뷰의 layer에서 애니메이션이 제거됩니다. 이상하게도 때로는 애니메이션이 view.layer.animationKeys.count == 0으로 지속될 수 있지만 대개는 그렇지 않습니다.

- (void)startAnimations 
{ 
    NSArray *visibleCells = self.tableView.visibleCells; 
    for (CustomTableViewCell *cell in visibleCells) { 
     [cell animateIfNeeded]; 
    } 
} 

@doNotCheckMyBlog, 여기 당신이 headerView '를 시작하는 방법 호출 할 수

가장 좋은 건 아마도 같은 방법을 통해, @vignesh_kumar을 위해 ... -viewWillAppear: 또는 -viewDidAppear:에 애니메이션을 시작하는 것입니다 애니메이션.

그 외에도 앱을 배경으로 시작한 다음 애니메이션을 다시 시작하면 애니메이션이 중지 될 것으로 생각됩니다.

앱을 다시 시작할 때 -startAnimations 방법으로 전화해야합니다. 예를 들어, 앱 대표는 -applicationDidBecomeActive: 또는 -applicationWillEnterForeground: 방법으로 NSNotification을 보낼 수 있습니다. MasterViewController은이 알림을 볼 수 있으며 수신하면 -startAnimations으로 전화 할 수 있습니다.

애니메이션에서 똑같은 상태로 돌아갈 필요가 없다면 큰 문제는 아닙니다. 앱이 백그라운드로 실행될 때와 동일한 애니메이션 상태로 돌아 가야하는 경우 상태를 저장 한 다음 애니메이션을 다시 시작할 때 초기 상태를 설정해야합니다.

+0

이 켜져 있습니다. 다음은 테이블에서 수행하는 방법입니다. http://stackoverflow.com/a/43877981/294884 – Fattie

관련 문제