UIButton在从IBOutlet引用时不会禁用,但在从IBAction引用时也不会禁用

时间:2012-05-15 17:21:17

标签: objective-c xcode uibutton

我已多次检查以确保我的连接在IB中正确。

// This does not work
UIButton *additionButton = [self.gameShopCoinButtonCollection objectAtIndex:0];
additionButton.enabled = NO;

// This does work
-(IBAction)gameShopBuyButtonPressed:(UIButton *)sender {
    sender.enabled = NO;
}

2 个答案:

答案 0 :(得分:0)

禁用 -

additionButton.userInteractionEnabled = NO;

答案 1 :(得分:0)

您无法保证IBOutletCollection中商品的顺序。您需要直接引用该按钮并以此方式禁用它。