objective-c – UIView animateWithDuration:动画:完成:应用变换,而不是动画

objective-c – UIView animateWithDuration:动画:完成:应用变换,而不是动画,第1张

概述试图从KVO观察中调用此消息.下载图像后,将发送此消息.完成块中的消息还包含一个正常工作的动画(动画正确).此动画应用没有动画发生的变换(等待动画的长度,然后跳转到最终状态). /** * Discover the subview with the supplied tag, attach the fullsize image to the view * scale to fullsize 试图从KVO观察中调用此消息.下载图像后,将发送此消息.完成块中的消息还包含一个正常工作的动画(动画正确).此动画应用没有动画发生的变换(等待动画的长度,然后跳转到最终状态).

/** *  discover the subvIEw with the supplIEd tag,attach the fullsize image to the vIEw *  scale to fullsize and begin retract. *  @param vIEwTag int - #FUTURE USE# - The tag of the vIEw to be animated. *  @param image UIImage - #FUTURE USE# - The image to be applIEd to the vIEw. *  @return voID */- (voID)animateVIEwWithTag:(int)vIEwTag andImage:(UIImage *)image {    Panel *activePanel = [self.panels objectAtIndex:currentIndex];    UIVIEw *activePanelVIEw = [self.vIEw vIEwWithTag:activePanel.panelID];    // display the Transition to the fullsize version of the panel image.    // Determine the scale that needs to be applIEd to the vIEw to show    // the image in the appropriate scaling. If scaled image is greater than    // the size of the screen,find the best fit.    @R_419_5987@ scale = image.size.wIDth / activePanelVIEw.frame.size.wIDth;    if (image.size.wIDth > self.vIEw.window.frame.size.wIDth || image.size.height > self.vIEw.window.frame.size.height) {        // The image will scale beyond the bounds of the window,scale must be adjusted.        scale = self.vIEw.window.frame.size.wIDth / activePanelVIEw.frame.size.wIDth;    }    CGAffinetransform transform = CGAffinetransformMakeScale(scale,scale);    [UIVIEw animateWithDuration:1.0                     animations:^{                         // Get the fullsize image and display it in the growing panel.                         [activePanelVIEw settransform:transform];                         [NSThread sleepForTimeInterval:3.0];                     }                      completion:^(BOol finished) {                         [self retractimage:activePanelVIEw];                     }];}#pragma mark - KVO- (voID)observeValueForKeyPath:(Nsstring *)keyPath ofObject:(ID)object change:(NSDictionary *)change context:(voID *)context {           int tmpInt = (int)context;            UIImage *tmpImage = [change objectForKey:NSkeyvalueChangeNewKey];    if ( keyPath == @"imgOriginal" ) {        [self animateVIEwWithTag:[(Panel *)object panelID] andImage:tmpImage];                 }   }
解决方法 线程睡眠的目的是什么?

如果你使主线程休眠,那么它不会在此期间更新动画.

如果你没有在主线程上调用它,那么它也不会起作用,因为UIKit动画不是线程安全的,只能从主线程中可靠地使用.

总结

以上是内存溢出为你收集整理的objective-c – UIView animateWithDuration:动画:完成:应用变换,而不是动画全部内容,希望文章能够帮你解决objective-c – UIView animateWithDuration:动画:完成:应用变换,而不是动画所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1225886.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存