2014-09-02 2 views
0

UIScrollView 내에서 UIImageViews 세트를 애니메이션 싶었습니다 (이미 완료되었습니다). 그러나 애니메이션은 사용자가 스크롤 뷰를 특정 위치로 스크롤 할 때만 시작됩니다. 즉, 해당 UIImageVIew가 표시 될 때만 애니메이션이 시작됩니다.UIScrollView에 표시 될 때만 객체에 애니메이션 적용

+0

직접적인 방법이지만 [이 답변] (http://stackoverflow.com/a/2950979/2857130) 도움이 될 것입니다. '-scrollViewDidScroll :'이 너무 자주 호출되기 때문에 무거워진다. 어쨌든 ... – staticVoidMan

답변

1
  1. 가있는 ScrollView 대리인의 scrollViewDidScroll:를 구현합니다.

  2. scrollViewDidScroll: 구현 : 스크롤 뷰의 contentView에 보이는 사각형을 가져옵니다. Here's how.

  3. 애니메이션하려는 하위보기가 CGRectContainsRect()을 사용하는 보이는 rect 내에 있는지 확인하십시오.

이 테스트하지만 도움이 희망되지 않습니다

- (void) scrollViewDidScroll:(UIScrollView *)scrollView 
{ 
    // get the scrollView's contentView visible rect 
    // from here: https://stackoverflow.com/questions/868288/getting-the-visible-rect-of-an-uiscrollviews-content 
    CGRect visibleRect; 
    visibleRect.origin = scrollView.contentOffset; 
    visibleRect.size = scrollView.contentSize; 

    if(CGRectContainsRect(visibleRect, rectOfScrollViewSubviewYouWantToAnimate)) 
    { 
      // NOTE: This will be called multiple times as the scrollview moves 
      // do your animation here: 
    } 
    else 
    { 
      // rectOfScrollViewSubviewYouWantToAnimate is out of scrollView Visible area 
    } 
} 
0

이 페이지로 이동하십시오. 그러면 도움이 될 것입니다. 나는 하나의 이미지 뷰에서 그것을 시도했다. 마찬가지로 코드의 모든 이미지 뷰에 대해이 작업을 수행 할 수 있습니다.

[블로그] : HTTP : //icodeguru.blogspot.in/2014/09/animated-imageview-stops-animating-when.html

관련 문제