故事板 ViewController.m
我在 viewDidLoad 中做了一个实验,我把:
NSLog(@"The View did load :-) %@", self.title);
放在 viewDidLoad 里面......所以每次我继续使用不同的视图时,我都会看到输出的变化,但我迷失在事物的“概念”基础中。
我应该将每个视图的代码放在哪里? Xcode 给了我一个 ViewController.m,但是我不应该为故事板中的每个视图创建一个单独的 ViewController.m,然后每个视图都有自己的 viewDidLoad 吗?
我刚刚观看了 Segues/Storyboarding 上的 WWDC 视频,并准备使用prepareForSegue:sender: 在我的视图之间传递数据。我没有接触过故事板的书。
I did an experiment in viewDidLoad where I put:
NSLog(@"The View did load :-) %@", self.title);
inside of viewDidLoad.... so each time I segue'd to my different views I watched the output change but I'm lost in the "conceptual" groundwork of things.
Where do I put my code for each view? Xcode gives me the one ViewController.m, but shouldn't I create a separate ViewController.m for each view that I have in my storyboard and then each view has its own viewDidLoad?
I just watched the WWDC video on Segues/Storyboarding and going to play around with prepareForSegue:sender: to pass data between my views. None of the books I have touch on Storyboarding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为每个视图创建单独的控制器,然后从界面生成器连接它们,当您将 ViewController 添加到项目中时...您将在下图中类旁边的下拉框中找到它们。因此,只需选择视图,然后选择一个红色循环选项卡,然后为该视图分配一个视图控制器:)
Visual
与其他视图相同,
Create separate controller for each View and than connect them from interface builder, When you will add ViewController in side your project...you will find them inside a drop box next to class in below images. So just select view and than select a red cycled tab and than assign a view controller for that view :)
Visual
Same with other views,