Reputation: 55
I am trying to hook up a UIButton
to a IBAction
in interface builder but IB will not show the method that I defined as an option to hook it up to.
- (IBAction)someAction:(id)sender;
That is what I have in the h file, and then in the M file I have
- (IBAction)someAction:(id)sender{
NSLog(@"Button Tapped."); }
The IB Document is connected to that class i know because that class also has a UIPicker
, and that connects fine.
Any help would be brilliant on this,
Thanks, Callaghan001.
Upvotes: 4
Views: 3863
Reputation: 9075
I had a this problem and restarting Xcode did not solve it.
What solved it for me was:
File Owner
Identity Inspector
(under Utilities
, right hand side panel).Custom Class
section, just select the text field (where your custom UIViewController
sub-class name should be displayed) and hit 'Enter'.Upvotes: 1
Reputation: 83
I think your implementation must be
- (void)someAction:(id)sender
{
NSLog(@"Button Tapped.");
}
Upvotes: -2
Reputation: 84
try adding -(IBAction)testFunction:(id)sender;
in the .h file.
It worked for me.
Upvotes: 1
Reputation: 11
same problem, reading class file in didn't fix it but changing the class name in the controller identity inspector from UIViewController to the correct subclass name did.
Upvotes: 1
Reputation: 41
I fixed this problem by reading in the Class file manually from Interface Builder. Just do File -> Read Class -> find the .h file you defined the IBAction in. -> open! Then Interface builder will say something like "one Class file parsed"
Upvotes: 4
Reputation: 1257
Make sure you're actually wiring up the handler for the button's event (probably touch up inside) and not the button itself. So instead of dragging directly from the button, either ctrl-click the button to see its connections and drag from its touch up inside event to the target, or ctrl-click the target, find the action, and drag from that to the button. If the action doesn't show up on the target in these cases, and you're sure interface builder knows what class it is, then I'm baffled.
Upvotes: 3