我希望能够拥有它,以便每次单击集合中的按钮时都会生成一张新卡。由于某种原因,这适用于 2 次点击,然后选定状态的标题变为 nil。谢谢你的帮助!
- (void) setButtonCollection:(NSMutableArray *)buttonCollection
{
_buttonCollection = buttonCollection;
for (UIButton *cardButton in self.buttonCollection){
Card *card = [self.deck drawRandomCard];
[cardButton setTitle:card.contents forState:UIControlStateSelected];
}
}
- (IBAction) flipCard:(UIButton *)sender {
sender.selected = !sender.isSelected;
[self setButtonCollection: self.buttonCollection];
}