iphone - Subclass of NSObject as target in addEventListener statement -
When setting the method of a button call or adding an event listener to the objective-c, The goal determines although I have NSObject named call , which is a sub-section different than the main file. In this subclass, a zero called METHOD_NAME , which should be executed.
The first question is that there will be METHOD_NAME in zero + (zero) METHOD_NAME
or
- (zero) subdivision.
Next how do I set the goal of using the NSObject and call the method inside it? Do i
target: [call square];
Or would I like to make an example of the subclass of NSObject (call) and then pass it?
-
"call" and "METHOD_NAME" a good name for class and method Are not there. Try to follow the objective-conventions. Since you are "nononso", you can make some calls to your class such as
NNEventListenerand methodbuttonTapped, for example. -
The first question: It really does not matter that both class methods (+) and example methods can be used. However , using an example method to listen to UI events will be very unusual for not , so the answer is, click the
- (zero) button addEventListener. Where did you hear of that? Are you already using the web framework to create an app?
One button (or any other UIControl code>), you use -addTarget: action: forControlEvents: For the context that you want to be called, you use these special @selector directives:
[One button addTarget: One object Action: @Selector (Button Tap) Control Events: UI ControlView Touchup Inside]; aButton - your button anObject - an object self is the only object that you have buttonTapped - any object in the object can give the name of the method that should be called when the button is tapped
Comments
Post a Comment