按下按钮时插入动作;代码是:
[UIView transitionWithView:self.btnCardFront1 duration:.5 options:UIViewAnimationOptionTransitionFlipFromLeft|UIViewAnimationOptionCurveEaseInOut
animations:^{
[self.btnCardFront1 setAlpha:0.0];
[self.btnCardBack1 setAlpha:1.0];
} completion:^(BOOL finished){}
];
我想将此代码插入到函数中,但是返回此错误: 使用未声明的标识符'self'
如何用my元素替换self? 感谢
答案 0 :(得分:2)
__block <MySelfType class> *blocksafeSelf = self;
[UIView transitionWithView:blocksafeSelf duration:.5 options:UIViewAnimationOptionTransitionFlipFromLeft|UIViewAnimationOptionCurveEaseInOut
animations:^{
[blocksafeSelf setAlpha:0.0];
[blocksafeSelf setAlpha:1.0];
} completion:^(BOOL finished){}
];
答案 1 :(得分:1)
你不必把自己放在那里,无论如何,如果自己不在那里它仍会有效。