ここに問題があります-UIView(カード)のサブクラスであるクラスがあります。それ自体にボタンを作成し、ユーザーがボタンに触れたときに changeStateIndicator: を呼び出しています。
次に、ボタンが押された後にカードを裏返す必要があり、ボタンの色 (実際には画像) が変わるはずです。しかし、それはまったく起こっていないので、ボタンが変更される前にフリップが開始されます。これが私のコードです:
//Adding a button to my view
UIButton *changeStateButton = [UIButton buttonWithType:UIButtonTypeCustom];
[changeStateButton setImage:[UIImage imageNamed:imageToInitWith] forState:UIControlStateNormal];
[changeStateButton setImage:[UIImage imageNamed:imageToInitWith] forState:UIControlStateHighlighted];
changeStateButton.frame = CGRectMake(0, 0, 30, 30);
changeStateButton.center = CGPointMake(self.bounds.size.width/2+([myWord length]*8)+17, 35);
changeStateButton.tag = 77;
[changeStateButton addTarget:self action:@selector(changeStateIndicator:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:changeStateButton];
//Method which is called when the button is touched
- (void)changeStateIndicator:(UIButton *)sender
{
[sender setImage:[UIImage imageNamed:@"StateYellow"] forState:UIControlStateNormal];
[sender setImage:[UIImage imageNamed:@"StateYellow"] forState:UIControlStateHighlighted];
currentWord.done = [NSNumber numberWithInt:currentWord.done.intValue-10];
[self prepareForTest];
}
//Method which flips the card
- (void)prepareForTest
{
testSide = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cal_small3"]];
[UIView transitionFromView:self toView:testSide duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:nil];
}
メソッド -changeStateIndicator が終了するまで、送信者は画像を変更しないと思いますが、これが実際の問題かどうかはわかりません。お願い助けて。