2011-12-01 6 views
2

나는 그들이 잇달아 발사 있도록 모두가 서로 다른 지연이 기본 형식에 따라 여러 애니메이션 블록을 사이에 지연 :목표 C, 애니메이션 블록, 애니메이션 및 완료

[UIView animateWithDuration:.85 delay:3 options:opts animations:[animations objectAtIndex:ww] completion:[completions objectAtIndex:ww]]; 

를 옵션은 단지 UIViewAnimationOptionAutoreverse 있습니다 변수에 쉽게 액세스 할 수 있습니다.

이미지가 원래 위치로 돌아 가기 전에 약간의 시간 동안 새로운 위치에 머물러있게하려면 애니메이션과 완성 사이에 지연이 있기를 원합니다. 몇 가지 더 간단한 animateWithDuration:animations: 블록을 사용해 보았습니다.하지만 뭔가 빠뜨린 경우를 제외하고는 문서의 지연으로이를 수행 할 방법을 찾지 못했습니다. 애니메이션이 한 지점에서 다른 다음 다시 이미지를 이동, 슈퍼 간단 참조

void (^completion)(void) = ^{ 
[UIView animateWithDuration:.5 
        delay:5 
       options:UIViewAnimationCurveLinear 
      animations:[completions objectAtIndex:ww] 
      completion:^(BOOL finished) {}]; 
}; 


// Call your existing animation with the new completion block 
[UIView animateWithDuration:.5 
        delay:1 
       options:UIViewAnimationCurveLinear 
      animations:[animations objectAtIndex:ww] 
      completion:^(BOOL finished) { 
       completion(); 
      }]; 

: Paul.s @

여기에 당신이 내게 준 것과 사용되는 코드입니다. 충돌 지점은 완료 블록이 정의 된 [UIView animateWithDuration:.5 행이며 애니메이션의 첫 번째 부분이 실행 된 후 충돌합니다.

답변

5

다른 애니메이션을 완료로 전달하는 것은 어떻습니까?

업데이트 됨 설정 한 샘플의 정확한 작동 코드가되도록 코드를 업데이트했습니다. 이것은 완료 애니메이션 실행을 시작하려고 할 때 그것이 EXC_BAD_ACCESS을 던지고

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 

    CGRect startFrame = CGRectMake(0, 0, 100, 100); 

    UIView *view = [[UIView alloc] initWithFrame:startFrame]; 
    view.backgroundColor = [UIColor greenColor]; 

    [self.window addSubview:view]; 

    // Set up your completion animation in a block 
    void (^completion)(void) = ^{ 
     [UIView animateWithDuration:0.5f 
           delay:0.5f 
          options:UIViewAnimationCurveLinear 
         animations:^{ 
          view.frame = startFrame; 
         } 
         completion:nil]; 
     }; 


     // Call your existing animation with the new completion block 
     [UIView animateWithDuration:4 
          delay:1 
          options:UIViewAnimationCurveLinear 
         animations:^{ 
          view.frame = CGRectMake(200, 200, 10, 10); 
         } 
         completion:^(BOOL finished) { 
          completion(); 
         }]; 



     self.window.backgroundColor = [UIColor whiteColor]; 
     [self.window makeKeyAndVisible]; 
     return YES; 
} 
+0

Empty Application 템플릿을 사용하여 설정 깨끗한 프로젝트를 사용하고 있습니다. 내가 필요로하는 번호로 전환했는데 코드가 잘 보이기 때문에 왜 그런 일이 일어나는지 확실하지 않다. – lunadiviner

+0

EXC_BAD_ACCESS가 사용 된 코드와 EXC_BAD_ACCESS가 발생한 위치를 표시 할 수 있습니까? '애니메이션 '에 대한 두 번 호출 외에도, 내가 게시 한 코드는 실제 예제에서 나온 것입니다. –

+0

은 기본 게시물을 업데이트했습니다. – lunadiviner

관련 문제