मेरे पास नेस्टेड UIView
एनिमेशन (किसी दिए गए समय में 2 या 3 स्तर गहरे) का एक सेट है जिसे मैं रोकना और फिर से शुरू करना चाहता हूं। इनमें से कुछ एनिमेशन -animateWithDuration:animations:completion:
का उपयोग करते हैं जबकि अन्य एनीमेशन ब्लॉक के निष्पादन में देरी के लिए -animateWithDuration:delay:options:animations:completion:
का उपयोग करते हैं।देरी के साथ एनीमेशन के साथ कैलियर एनीमेशन को रोकना
मैंने एक परत पेड़ में सभी एनिमेशन को रोकने के बारे में Technical Q&A QA1673 पढ़ और कार्यान्वित किया, लेकिन मुझे देरी पैरामीटर का उपयोग करने वाले एनिमेशन के साथ कोई समस्या आ रही है। मैं एनीमेशन को रोक सकता हूं और फिर से शुरू कर सकता हूं, लेकिन जब एनीमेशन फिर से शुरू होता है, तो एनीमेशन ब्लॉक जिसमें इसके साथ जुड़ी देरी होती है, उसमें देरी होती है जब परत पेड़ को रोका गया था। तो उदाहरण के लिए, यदि किसी एक ब्लॉक में 1 सेकंड की देरी हो रही है, और परत पेड़ को 3 सेकंड के लिए रोक दिया गया था, तो एनीमेशन फिर से शुरू होने के 4 सेकंड बाद देरी हो जाती है। मुझे लगता है कि beginTime
संपत्ति के साथ इसका कुछ संबंध है? किसी भी सहायता की सराहना की जाएगी।
// Pause and Resume methods, right from the technical Q&A
- (void)pauseAnimationsOnLayer:(CALayer *)layer
{
CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
layer.speed = 0.0;
layer.timeOffset = pausedTime;
}
- (void)resumeAnimationsOnLayer:(CALayer *)layer
{
CFTimeInterval pausedTime = [layer timeOffset];
layer.speed = 1.0;
layer.timeOffset = 0.0;
layer.beginTime = 0;
CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
layer.beginTime = timeSincePause;
}
// Chained animations
- (void)animateNextPopup
{
[UIView animateWithDuration:kRFPVictorySequenceStatePopupDuration
animations:^{
[_currentStateImageView setHidden:NO];
[_currentStateImageView setTransform:CGAffineTransformIdentity];
}
completion:^(BOOL finished) {
[UIView animateWithDuration:kRFPVictorySequenceStateSlideOffDuration
delay:kRFPVictorySequenceStateVoteDelay
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
if (winnerIsDem) {
[_currentStateImageView setFrame:CGRectMake(-_currentStateImageView.frame.size.width,
_currentStateImageView.frame.origin.y,
_currentStateImageView.frame.size.width,
_currentStateImageView.frame.size.height)];
}
else {
[_currentStateImageView setFrame:CGRectMake(1024,
_currentStateImageView.frame.origin.y,
_currentStateImageView.frame.size.width,
_currentStateImageView.frame.size.height)];
}
}
completion:^(BOOL finished) {
// Do some stuff
}
];
}
];
}
प्रतिक्रिया के लिए धन्यवाद, लेकिन इस विचार में वास्तव में भी अपने स्वयं के मुद्दे हैं। मानक 'एनएसटीमर' का उपयोग करना एनीमेशन को डिवाइस की डिस्प्ले रेट के साथ सिंक नहीं करेगा जो एनीमेशन को चंचल दिखने का कारण बन सकता है। एक 'CADisplayLink' का उपयोग करना बेहतर होगा जो कि समान है लेकिन डिस्प्ले के साथ समन्वयित करने के उद्देश्य से बिल्कुल बनाया गया है। फिर भी, ~ 10 धारावाहिक एनिमेशन चलाने के लिए एक डिस्प्ले लिंक ऑब्जेक्ट का उपयोग करके कुछ गंभीर स्पेगेटी कोड हो सकता है। आखिरकार, मेरा सवाल है * क्यों * एक परत पेड़ में एनिमेशन को रोकता है * बाद * एनिमेशन के लिए देरी मान को प्रभावित करता है? अजीब लगता है, नहीं? – Sean
"कुछ गंभीर स्पेगेटी कोड" ... हाँ, आप सही हैं ... लेकिन आखिरकार मैं इतालवी हूं;) – Beppe