How to add an action to a UIButton -
I am searching for this answer online, and leaves every post for that part where really Writing code is an action. I have a simple interactive UIButton and if I can only see a template of a code which is "written code for action", then it would be super helpful !!! (This iPad is for iOS 7)
This is as far as I can get ...
UIButton * button = [UIButton buttonWithType: UIButtonTypeRoundedRect]; [Button addTarget: auto-action: @sillector (one method :) control events: UIControlEventTeaDown]; [Button Settital: @ State for "Show View": UIC ControllantAnnoral]; Button.frame = CGRectMake (80.0, 210.0, 160.0, 40.0); [See adviewview: button]; I think that I understand how this is a potential action set, but where did I write the actual code for self action?
I already responded to it, want to expand it, both responses are correct But I have to tell how all this works. [Button addTarget: Self-action: @ Selector (aMethod :) Control events: UIControllViewTouchdown]; First to see; targets . The goal is a square, an example of any class. The only requirement for this class is that it has to implement the verb . Actions is the method you can invite when pressing the button. @selector (aMethod :) Actually think of it as a method signature. Since the objective is a dynamic language, aMethod: does not require existence, but if your program is not, then it will crash. So if we keep all this together, whenever I want to press this button:
System verb will call for example. And the method itself for this, it can look like this
- (zero) aMethod: (ID) sender {} < / Div>
Comments
Post a Comment