转载自: http://zhidao.baidu.com/link?url=YsSDzoiAJ5n-Oc8uk_tpMWiE1WD1L9ixKGDHB8UJnR7lC9fTxwuClXbudIh-Fgpd4G2CSymVY3QqvhrrmNhffRnexStN4lYJ0ALHaJ7zsDq
你可以做这样的假设你已经创建了一个取消的财产。作为块的startAnimation调用记录需要被包裹在一个异步调用,以避免堆栈溢出.a定要与任何类类型你确实有更换“身份证”。- (void)startAnimation {
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction
animations:^(void) {
//animate
}
completion:^(BOOL finished) {
if(!self.canceled) {
__weak id weakSelf = self;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[weakSelf startAnimation];
}];
}
}
];
}
本文介绍了如何在处理特定任务时使用异步调用来避免堆栈溢出,通过实例展示了在iOS开发中如何正确地封装`startAnimation`函数,确保程序的稳定性和效率。
349

被折叠的 条评论
为什么被折叠?



