在故事板 xcode 4 中添加的视图控制器的 .h 和 .m 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8707670/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.h and .m files for view controllers added within storyboard xcode 4
提问by Matt Rosemeier
I've created the flow of my application with storyboard. It's a navigation based storyboard layout with a few stacks of views. Where can I create .h and .m files to actually make the app DO things? The general navigational flow of the app is just fine as a result of story board, but I need to add my own code to the views. Thanks!
我已经用故事板创建了我的应用程序的流程。这是一个基于导航的故事板布局,带有一些视图堆栈。我在哪里可以创建 .h 和 .m 文件来实际使应用程序执行操作?由于故事板,应用程序的一般导航流程很好,但我需要将自己的代码添加到视图中。谢谢!
回答by Greg
Go to File->New->New File and create a UIViewSubclass without the xib/nib for each view that you have. This will create the .h and .m files. Then, select the view in the storyboard and go to Identity Inspector in the right column view. Under Custom Class->Class, select the new UIViewSubclass (by name) that you just created. This will link the view with the header and implementation files.
转到 File->New->New File 并为您拥有的每个视图创建一个没有 xib/nib 的 UIViewSubclass。这将创建 .h 和 .m 文件。然后,选择故事板中的视图并转到右侧列视图中的 Identity Inspector。在 Custom Class->Class 下,选择您刚刚创建的新 UIViewSubclass(按名称)。这会将视图与头文件和实现文件链接起来。