Touch Up Inside fine, Touch Down Not

H

haarlequin

Guest
When I change the Sent Event of a button in interface builder from Touch Up Inside to Touch Down, I fail to trigger the IBAction.

Any idea why? Am I missing something obvious?

Cheers.
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
You have to drag from the UIButtons connections inspector to the app delegate, or view
controller class, and select the desired IBAction method.

By default all UIButton action events are set to touch up inside, and connected to the app
delegate with that connection, but you can also have any number of the other action
methods also connected to the same method.

Try and right click the button, then drag from the round connection marker, next to the touch
down action, and drag to the class object cube where the IBAction method is implemented,
and then select the method from the list.

Regards Mark
 
OP
H

haarlequin

Guest
Thanks Mark,

what's the difference between selecting the IBAction in the first responder and selecting it in the View Controller?

And if you want a laugh: I was changing the iphone Storyboard and testing it in the iPad simulator.

Bugger.
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
The First Responder cube object in the Interface Builder is an abstract class, that really
represents nil, in the standard Xcode templates the first responder is linked to the main window, and is the first place all user nil target action events are sent, then the window
forwards thes action events up the responder chain,

The main menu for the application in the standard template also has its methods connected
to the first resopnder, most controls views windows and the application itself are all in the
responder chain, if you want a particular control or project class to be the first responder,
then override the method below.

Code:
- (BOOL)canBecomeFirstResponder
{
        return YES;
}

For example

Code:
[[self view] becomeFirstResponder];

If you want you control or class to resign being the first responder, then send it the message
below.

Code:
[[self view] resignFirstResponder];

If your starting out as a beginner, then I would leave the standard project template first
responder set up as is, that way you can be sure that what ever view is currently on the
main window, it will recieve the user action events.

Regards Mark
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top