禁用xcode中的按钮

时间:2011-11-17 21:26:54

标签: iphone objective-c cocoa-touch ipad uibutton

在我的项目中,我有一个通过IBOutlet调用函数的按钮,我需要知道如何在功能代码中添加禁用按钮,因为我识别按钮(使用标签?)
写什么?

3 个答案:

答案 0 :(得分:3)

我觉得你有点困惑。您的按钮通过IBAction连接到方法。您需要为按钮创建@property并通过IBOutlet将其连接到IB。

或者,您可以使用IBAction中的sender参数。这样的事也许......

- (IBAction)buttonPressed:(id)sender
{
    UIButton *buttonThatWasPressed = (UIButton *)sender;
    buttonThatWasPressed.enabled = NO;
}

答案 1 :(得分:2)

很简单。

self.yourButton.enabled = NO;

答案 2 :(得分:0)

对于像这样的make代码

button.enabled=NO;

&安培;如果你想启用像这样的agaian代码

button.enabled=YES;