我有一个UIView animateWithDuration(在由按钮调用的方法中)为UIImageViews. 动画代码前的重要代码:(标题贴切,继续看下去)
//Sets _squareOneNumber to 0 (this is going to be the changing value)
_squareOneNumber = 0;
基本上,动画代码只允许用户交互并以随机速度将图像动画到屏幕下方。
但是,是完成块杀死了我(不用担心aand b):
if (self.squareOneNumber==0) {
if (a==b) {
[self gameOverImagePutter];
NSLog(@"One wasn't pressed");
}
}
如果按下它,值将_squareOneNumber变为 1。
//In touchesBegan method
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
if ([self.squareOne.layer.presentationLayer hitTest:touchLocation]) {
[_squareOne setHidden:YES];
_squareOneNumber = 1;
}
gameOverImagePutter如果squareOne未按下 ( squareOneNumber=0) 和 ,则完成块应调用a==b。但它总是在squareOne 按下( squareOneNumber=1) 时调用。对我来说,代码应该可以正常工作。但我认为问题在于,squareOneNumber即使它的价值发生了变化,它也没有得到更新。
所以基本上这是我的问题:
- 如何让代码工作?
- 为什么没有
squareOneNumber意识到它的价值已经改变?