开发者

Interface Builder will not see action methods

开发者 https://www.devze.com 2023-01-16 18:35 出处:网络
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.

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.


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"


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.


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.


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

It worked for me.


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'.


I think your implementation must be

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

精彩评论

暂无评论...
验证码 换一张
取 消