没有故事板的编码

coding without storyboards

我正在观看有关如何允许用户编辑其个人资料的教程视频。在本教程中,他们使用的是故事板,而我没有。我在想,我是否必须使用故事板才能跟进?或者我可以在没有故事板的情况下使用他们的代码插入我的代码吗?

根据 Apple 文档:

A storyboard is a visual representation of the user interface of an iOS application, showing screens of content and the connections between those screens. A storyboard is composed of a sequence of scenes, each of which represents a view controller and its views; scenes are connected by segue objects, which represent a transition between two view controllers.

正如您可能猜到的那样,故事板包含有关您要添加的代码所需的小部件、动画和视图的信息 to yours。此外,故事板还包含视觉元素和代码(出口和动作)之间的联系。所有这些都可以通过编程方式创建,但是您将从本教程中粘贴的代码(如果它来自包含故事板的项目)将不包含此相关逻辑。

因此,在这一点上,增加教程的复杂性以立即重新创建这些元素似乎是非常不明智的。我建议您按照教程进行操作,然后尝试删除其中一些元素并用代码替换它们以获得类似的结果,就像学习练习一样。请记住,Storyboards 一直在简化应用程序中 UI 的设计,因此我建议您掌握它们的用法,而不是回避它们。