Builder interface will not see action methods

I am trying to connect UIButton to IBAction in the interface builder, but IB will not show the method that I defined as an option to connect it.

 - (IBAction)someAction:(id)sender; 

This 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 this class, which I know, because this class also has a UIPicker , and it connects perfectly.

Any help would be brilliant on this,

Thank Callaghan001

+4
source share
6 answers

Make sure that you actually connect the handler to the button event (maybe touch it inside), and not to the button itself. Therefore, instead of dragging directly from the button, either press Ctrl to see its connections and drag it from the touch inside the event to the target, or press Ctrl-target, find the action and drag it using the button. If in these cases the action is not displayed on the target and you are sure that the interface builder knows what class it is, then I am puzzled.

+3
source

I fixed this problem by reading in the Class file manually from Interface Builder. Just do File -> Read Class -> find the .h file in which you defined the IBAction. → open! Then the interface constructor will say something like "one class file processed"

+4
source

the same problem, reading the class file did not fix it, but changed the class name in the controller identification inspector from UIViewController to the correct subclass name.

+1
source

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

It worked for me.

+1
source

I had this problem and restarting Xcode did not resolve it.

For me it was decided:

  • Choose File Owner
  • Go to the Identity Inspector (under Utilities , right side of the panel).
  • In the Custom Class section, simply select the text box (where your subclass name UIViewController should be displayed) and press 'Enter'.
+1
source

I think your implementation should be

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

All Articles