将视图控制器中的 IBAction 连接到选项卡栏控制器
对于选项卡栏应用程序:
使用 Interface Builder 在文件视图控制器中从选项卡栏视图连接到 IBAction 时遇到了一段痛苦的时光。
我相信基础知识很简单;即,从 Controller 到 View 按住 Control 拖动以生成 IBOutlet,从 View 到 Controller 按住 Control 拖动以生成 IBAction。
编写。
-(IBAction )some:(id)sender;
我已在 FirstViewController.h 和
-(IBAction )some:(id)sender
{
NSLog(@"some");
}
FirstViewController.m 中
当我单击 MainWindow.xib,然后按住 Control 键单击选项卡栏控制器下的第一个视图控制器时,我会看到“已接收的操作”。
但是,运行 iApp 后,我在控制台中看不到“某些”。
一个更基本的问题肯定会显示我的无知,但我会抓住机会:
如果我在 MainWindow.xib 显示到 .m 源文件夹并停留在 -(IBAction ) 时从第一个视图控制器中控制拖动some {...},我不应该看到一个弹出窗口或显示“连接”的内容吗?
约翰·洛夫
For a Tab Bar app:
Using Interface Builder I am having a miserable time making a connection from a Tab Bar View to a IBAction in a File View Controller.
I believe the basics are simple; namely, control-drag from a Controller to a View to generate a IBOutlet and control-drag from a View to a Controller to generate a IBAction.
I have written
-(IBAction )some:(id)sender;
in the FirstViewController.h and
-(IBAction )some:(id)sender
{
NSLog(@"some");
}
in FirstViewController.m
When I click on MainWindow.xib and then control-click on First View Controller under Tab Bar Controller I see the "Received Actions some".
But, I do not see "some" in the Console after I run the iApp.
A much more basic question that will definitely show my ignorance, but I'll take a chance:
If I control-drag from the First View Controller when MainWindow.xib is showing over to the .m source folder and rest over -(IBAction )some {...}, shouldn't I see a popup or something that says connect.
John Love
为什么需要 IBAction?
UITabBarController
将自行处理用户在选项卡按钮中的点击。您只需指定 XIB 的名称即可使该选项卡正常工作。Why do you need the
IBAction
? TheUITabBarController
will handle the user taps in the tab button by itself. You just need to specify the name of your XIB in order to make the tab work.