2010-07-15 3 views
1

나는 오프 스크린에서 온 스크린으로 움직이는 몇 개의 UIButtons를 포함하는 UIView를 가지고 있습니다. 그들이 향하고있는 지역은 클릭하기 전에 클릭 할 수 있다는 것을 알았습니다. 애니메이션은 꽤 간단하기 때문에 최종 목적지에있는 것처럼 버튼을 처리하지 않도록 코드를 말하지 않는다는 것이 명백한 것인지 궁금합니다. 예상되는 행동이 될 수 있고 애니메이션은 순전히 시각적이며 클릭 가능한 지역은 목적지에서 즉각적이지만 시각적 인 것은 아닙니다.애니메이션 UIButtons는 대상에 도달하기 전에 대상에서 클릭 가능합니다.

다음은 내가 애니메이션을 적용하는 데 사용하는 코드입니다. 그것은 기본적으로 서브 패널을 전환 버튼과 메인 패널 다시 데려 : 당신이 애니메이션을하기 전에 패널을 사용자 상호 작용을 비활성화 할 수 있습니다 해결 방법으로

// switch back to main abilities panel 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration: kFadeInTime]; 
    CGRect rect = CGRectMake(
     480.0f, 
     mAbilities.mSubPanel.frame.origin.y, 
     mAbilities.mSubPanel.frame.size.width, 
     mAbilities.mSubPanel.frame.size.height); 
    mAbilities.mSubPanel.frame = rect; 
    [UIView commitAnimations]; 

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration: kFadeInTime]; 
    [UIView setAnimationDelay: kFadeInTime]; 
    rect = CGRectMake(
     kAbilitiesBorderX, 
     mAbilities.mPanel.frame.origin.y, 
     mAbilities.mPanel.frame.size.width, 
     mAbilities.mPanel.frame.size.height); 
    mAbilities.mPanel.frame = rect; 
    [UIView commitAnimations];  

답변

1

을하고 다시 활성화 할 때 애니메이션 마감 :

// Animation compete handler 
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context{ 
    mAbilities.mSubPanel.userInteractionEnabled = YES; 

} 

// Animating panel 
mAbilities.mSubPanel.userInteractionEnabled = NO; 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration: kFadeInTime]; 
[UIView setAnimationDelegate: self]; 
CGRect rect = CGRectMake(
    480.0f, 
    mAbilities.mSubPanel.frame.origin.y, 
    mAbilities.mSubPanel.frame.size.width, 
    mAbilities.mSubPanel.frame.size.height); 
mAbilities.mSubPanel.frame = rect; 
[UIView commitAnimations]; 

당신이 iOS4를 대상으로하는 경우 블록 기반 애니메이션 API를 사용 (스펙해야한다고 같이)을 수행 할 수 있습니다 블록을 사용하여 애니메이션 동안

[UIView animateWithDuration:5.0f delay:0.0f options:UIViewAnimationOptionLayoutSubviews 
     animations:^(void){ 
      CGRect rect = CGRectMake(
            480.0f, 
            mAbilities.mSubPanel.frame.origin.y, 
            mAbilities.mSubPanel.frame.size.width, 
            mAbilities.mSubPanel.frame.size.height); 
         mAbilities.mSubPanel.frame = rect; 
     } 
     completion:NULL 
    ]; 

를 사용자 상호 작용을 사용할 수 없습니다 기본적으로 - 옵션 매개 변수에 UIViewAnimationOptionAllowUserInteraction 플래그를 설정하여 사용하도록 설정할 수 있습니다.

... options:UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionAllowUserInteraction ... 
+0

제안 해 주셔서 감사합니다. 내가 경험 한 것이 예상 된 행동인지 알기 위해 당신은 일어요? 애니메이션이 코딩 된대로 작동합니까? 이벤트 캡쳐가 이미 대상에서 활성화되어 있습니까? – Joey

관련 문제