开发者

Cannot get button to call controller code iPhone 4

开发者 https://www.devze.com 2023-03-05 13:03 出处:网络
My View has a button, myButton, in my XIB. In the XIB the File\'s Owner is of class HelloWorldViewController. And the view for File\'s Owner is my View in the XIB.

My View has a button, myButton, in my XIB. In the XIB the File's Owner is of class HelloWorldViewController. And the view for File's Owner is my View in the XIB.

In the HelloWorldViewController(which resi开发者_开发技巧des in MainWindow.XIB) I have - (IBAction) doMyButton:(id)sender and I have the corresponding definition in the HelloWorldViewController.h file.

For my View I have Events (again in the XIB) Touch Up Inside --> File's Owner doMyButton.

For File's Owner I have Received Actions doMyButton --> Rounded Rect Button Touch Up Inside.

I have a debug point on the first line of code that is inside the 'doMyButton' method. When I touch the button (with my mouse in the simulator) I do not hit my break point.

WTF?

Screen Captures of IB if it helps:

Overview

Properties Of Button


If every thing is fine then you are not setting the break point i.e. you are running your code using cmd+R use cmd+y or cmd+enter. cmd+r will run without considering your break points.


Do any of your IBOutlet items function?

If they don't (and since you renamed your XIB file), be sure the File's Owner has the correct custom class set in the interface builder. Otherwise it could be calling the wrong class which could be why your break point isn't firing.

Note: This is unlikely as such an issue should cause a build problem, but I've seen stranger things happen.


Thanks to a co-worker I found out what the problem was. The view I had with the button was in my HelloWorldViewController.xib as it is supposed to be. However, I had drug that view into the Main.xib to be the primary view for the NavController I had setup. I was editing the view in the HelloWorldViewController.xib when I should have been editing (read: making the connections) in the Main.xib where the view was duplicated for the NavController.

I assumed that NavController was simply pointing to the other XIB where my original view was defined, not running off a copy of it. Kind of messed up for a newb perspective.

0

精彩评论

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