IOS-dagi NSNotificationCenter-da ifodalangan bo'lsa

Bitta tugagach, yana bir animatsiyani boshlashga harakat qilaman.

Men shunga o'xshash chaqiruvlarni tekshiraman:

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(animationDidStopNotification:) 
name:ImageAnimatorDidStopNotification 
object:animatorViewController];

ImageAnimatorDidStopNotification qabul qilinganda menga nimadir tetiklashiga imkon beradigan if-statementni qanday qilishim kerak?

Rahmat!

0

2 javoblar

animationDidStop yordamida animatsiyalashgan animatsiyalar juda oddiy stsenariylar uchun foydalidir. Biroq, har qanday murakkab narsa uchun u tezkor bo'lib qoladi.

Apple tomonidan tavsiya etilgan juda yoqimli yondashuv CAMediaTiming protokolidan foydalanishdir.

Ular 421-sonli "Core Animation Essentials" ning " WWDC 2011" videosida ajoyib misollarni keltiradi. . Buni yuqoridagi havola orqali topasiz. Bunga kirish uchun siz ishlab chiquvchi hisobga muhtoj bo'lasiz.

"Bildirish va vaqt belgilari" maslahati uchun videoda 42:36 ga tez oldinga boring.

4
qo'shib qo'ydi

Siz nima qilmoqchi bo'lganingizni va muammo qaerda ekanligini bilish uchun etarlicha kod yubormadingiz.

Agar siz UIKit bilan ikkita (yoki ko'proq) animatsiyani zanjirlashni istasangiz, setAnimationDidStopSelector: selektoridan foydalaning.

- (void)startAnimating
{
    [UIView beginAnimations: @"AnimationOne" context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(animationOneDidStop:finished:context:)];
    /* animation one instructions */
    [UIView commitAnimations];
}

- (void)animationOneDidStop:(NSString*)animationID 
                   finished:(NSNumber*)finished 
                    context:(void*)context
{
    [UIView beginAnimations: @"AnimationTwo" context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(animationTwoDidStop:finished:context:)];
    /* animation two instructions */
    [UIView commitAnimations];
}

- (void)animationTwoDidStop:(NSString*)animationID 
                   finished:(NSNumber*)finished 
                    context:(void*)context
{
    [UIView beginAnimations:@"AnimationThree" context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    /* animation three instructions */
    [UIView commitAnimations];
}
0
qo'shib qo'ydi