iPhone SDK:以编程方式更改IBAction

Mat*_* S. 1 iphone uibutton ibaction

有没有办法可以通过编程方式更改UIButton的IBAction?

我知道我可以创建两个按钮并使用button.hidden = BOOL,但我更愿意只更改IBAction本身.

Ste*_*ntz 12

当然.您可以手动使用addTarget:forControlEvents:removeTarget:action:forControlEvents:管理操作方法和控件之间的连接.两种方法都在UIControl.

  • [button addTarget:self action:theIBA for forControlerEvents:UIControlEventTouchDown],假设self响应了IBM (4认同)