잘 작동하는 네 개의 NSTimer가 있습니다. 유일한 문제는 두 사람이 발사해야하고 나머지 두 사람은 첫 두 사람의 중간에 발사해야한다는 것입니다.비틀 거리는 NSTimer 화재
initTimer = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector: @selector(initText) userInfo:nil repeats:YES];
animateTimer = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector: @selector(textGlow) userInfo:nil repeats:YES];
initTimer1 = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector: @selector(initText1) userInfo:nil repeats:YES];
animateTimer1 = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector: @selector(textGlow1) userInfo:nil repeats:YES];
initText 및 initText1 방법이 게으른 인스턴스와 UILabel의를 생성하고 같은 장소에 화면에 배치 : 여기 내 코드입니다. textGlow 및 textGlow1 메서드는 텍스트를 더 크게 만들고 사라지도록 애니메이션을 적용합니다. initText1과 textGlow1을 initText와 textGlow의 중간에 시작하겠습니다. 예를 들어,이 두 메서드가 각각 2 초 (애니메이션 지속 시간을 2 초로 설정) 걸렸다 고 가정 해 봅시다. initText 및 textGlow를 시작한 다음 initText1 및 textGlow1에서 1 초씩 실행합니다.
감사합니다. 질문에 대답하는 데 도움이되는 다른 코드가 필요한 경우 그냥 물어보십시오.
---------- 편집 ------------- 일하지만 문제가
@MDT. 내가 한 것은 initTimer1 및 animateTimer1의 코드를 initTimer1Wrapper 및 animateTimer1Wrapper라는 새로운 함수에 배치 한 것입니다. 그런 다음 코드 [self performSelector:@selector(initText1Wrapper) withObject:nil afterDelay:1.0];
을 복사하여 복제했지만 선택기를 animateText1Wrapper로 변경했습니다. initText 및 textGlow가 계획대로 실행되고 initTimer1 및 animateTimer1이 1 초 동안 실행되지만 예상치 않게 initText 및 textGlow가 나머지 1 초를 마칩니다. 애니메이션은 그만합니다. 내가 그들이 와 [UIView commitAnimations]
과 UIView 애니메이션과 UIView 애니메이션이 동시에 실행할 수 없습니다 더 많은 이유가 있다고 생각합니다.
이 문제를 해결하려면 Core Animation을 사용해야하나요? 아니면 다른 해결책이 있습니까? 감사.
---------- EDIT2 -------------
또한, 당신이 아는 것이 중요하다 단지 경우, 나는이 애니메이션을 기각합니다 UIGestureRecognizer입니다. 같은 뭔가 :
if(screenIsTapped){
[initTimer invalidate];
[animateTimer invalidate];
[initTimer1 invalidate];
[animateTimer1 invalidate];
}
마음에 드는대로 한 번에 많은 UIView 애니메이션을 실행할 수 있습니다 (한도 내에서 가능). 각 애니메이션 객체에 고유 한 "animationID"(@ "name"값)를 부여해야합니다. –