Callaghan001
Callaghan001

Reputation: 55

Interface Builder will not see action methods

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

Answers (6)

Nikolay Suvandzhiev
Nikolay Suvandzhiev

Reputation: 9075

I had a this problem and restarting Xcode did not solve it.

What solved it for me was:

  1. Select File Owner
  2. Go to Identity Inspector (under Utilities, right hand side panel).
  3. Under Custom Class section, just select the text field (where your custom UIViewController sub-class name should be displayed) and hit 'Enter'.

Upvotes: 1

user427179
user427179

Reputation: 83

I think your implementation must be

- (void)someAction:(id)sender
{
    NSLog(@"Button Tapped.");   
}

Upvotes: -2

Govind
Govind

Reputation: 84

try adding -(IBAction)testFunction:(id)sender; in the .h file.

It worked for me.

Upvotes: 1

user788933
user788933

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

Whopper
Whopper

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

zem
zem

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

Related Questions