继续尝试理解 Objective-C 中的块。我有以下功能:
typedef void(^TAnimation)(void);
TAnimation makeAnim(UIView *aView, CGFloat angle, CGFloat x, CGFloat y,
CGFloat width, CGFloat height, UIInterfaceOrientation uiio) {
return Block_copy(^{
aView.transform = CGAffineTransformMakeRotation(angle);
aView.frame = CGRectMake(x, y, width, height);
[UIApplication sharedApplication].statusBarOrientation = uiio;
});
}
当我尝试执行以下操作时:
TAnimation f = makeAnim( ... );
f();
我得到一个 EXC_BAD_ACCESS。但是,如果我改为执行以下操作:
TAnimation f = makeAnim( ... );
[UIView animateWithDuration:0 delay:0 options:0 animations:f completion:NULL];
它工作正常。第一种情况有什么问题?