我有一個名爲change shape
功能:奇怪的UILabel和UIButton的行爲
- (void)changeShape {
NSLog(@"**** CHANGE SHAPE ****");
/* Set previous shape to current shape */
self.previousShape = self.currentShape;
/* Transition old shape out of view */
[UIView animateWithDuration:.4 animations:^(void){
[self.shapeButton setCenter:CGPointMake(self.view.frame.size.width+200, self.view.frame.size.height/2)];
} completion:^(BOOL finished){
if (finished) {
/* Set new current shape */
self.currentShape = [NSString stringWithFormat:@"%@",self.shapes[(arc4random() % [self.shapes count])]];
[self.shapeButton setImage:[UIImage imageNamed:self.currentShape] forState:UIControlStateNormal];
/* Transition new shape into view */
[self.shapeButton setCenter:CGPointMake(-200, self.view.frame.size.height/2)];
[UIView animateWithDuration:.3 animations:^(void){
[self.shapeButton setCenter:CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2)];
} completion:^(BOOL completed){
if (completed) {
[self changeScore];
}
}];
}
}];
}
- (void)changeScore {
self.score++;
[self.scoreLabel setText:[NSString stringWithFormat:@"%i",self.score]];
}
此功能使一個UIButton關閉屏幕,然後動畫回來到屏幕上。在最終動畫結束時,我想增加分數並在屏幕上更改UILabel
。出於某種原因,UIButton上的圖像只會在UILabel更改後纔會更改。有人知道這可能是爲什麼嗎?
@dasblinkenlight我在說,setImage似乎在外部完成塊內的完成塊之後執行。知道我在說什麼? – Apollo 2014-10-28 20:11:46