Is there a way I can programmatically change the IBAction of a UIButton?
I know I can just create two buttons and use button.hidden = BOOL, but I'd much rather just change the IBAction itself.
Is there a way I can programmatically change the IBAction of a UIButton?
I know I can just create two buttons and use button.hidden = BOOL, but I'd much rather just change the IBAction itself.
I'm not sure I understand the question? Why not have the IBAction call a custom method and put some logic about which action to take in that method?
Sure. You can use addTarget:forControlEvents:
and removeTarget:action:forControlEvents:
to manage the connections between action methods and controls manually. Both methods are in UIControl
.
Sure:
-removeTarget:action:forControlEvents: to remove the old action
-addTarget:action:forControlEvents: to add the new action