开发者

iphone SDK: Why is my button not firing my function?

We have place a button on a view. 开发者_开发问答When we press it, nothing happens. It should be firing a function we have defined. This is what we have done.

We have used interface builder to map the touch up inside event to our function_A. We verify this by right clicking on our view controller and the mapping is there under the received actions section.

What else needs to be done to make this work?


Make sure you have saved the nib in IB before building the app in Xcode to make sure it has the latest version of the nib that definitely has your action hooked up to the button.

At the top of the corresponding IBAction method, use

NSLog(@"Button was pushed");

to see in the console whether it's actually responding to the action, or if there's some other problem in your function.


Make sure the view has "User Interaction Enabled" under View Attributes in interface builder.


In Interface Builder have you defined a function and checked that it is available for connection by seeing that it appears in Class Actions, in the Identity Inspector? Does the specification exactly match the function? Be particularly careful that if your function takes no arguments it has no colon after the name, and if it is the usual

- (IBAction)method:(id)sender

signature then it does have a colon.

Have you used the Connections Inspector to connect the "Touch Up Inside" action of the button object to a function? When you look at Connections Inspector for Files's Owner (or whatever object contains the button function) can you see the connection exists?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜