Using XCode 4, I created a NEW TabBar Application using the default storyboard settings.
I开发者_如何学编程n my FirstViewController, I created a method called
- (IBAction)testMethod:(id)sender
In the UI (Interface Builder), I CTRL and dragged from the button to the FirstViewController and connected it to the method )testMethod.
However the methods never fire when the button is tapped.
Any help would be appreciated.
I am not completely sure I understand what you are trying to accomplish, however, I will take a guess and see if this helps...
If you run the App, the tab controller will switch between views when you tap the First and Second buttons on the tab bar. I am guessing that you want to know when the First button is tapped and you are trying to get the button to fire off a different message (testMethod). If this is correct, you may want to become a UITabBarDelegate rather than hooking the button. This will allow you to control how the TabBar switches views. You can prevent or allow the switch in tabBarController:shouldSelectViewController: and react to the switch in tabBarController:didSelectViewController:.
If this is not what you are trying to do, please elaborate on what you mean by "the button" in "dragged from the button" and perhaps even some insight into what the intention of testMethod is would help.
精彩评论