简体   繁体   English

ios-代码VS故事板意见

[英]ios - Code VS Storyboard opinion

I have just spend a lot of hours re writing my app to have it all in code instead of using storyboard. 我只是花了很多时间重新编写我的应用程序,使其全部用代码编写,而不是使用情节提要。 Mainly because I wanted to understand what the storyboard did for me. 主要是因为我想了解情节提要为我做了什么。

Obviously with this, I have noticed that my files have become severely big in terms of lines of code. 显然,我注意到我的文件在代码行方面变得非常大。

Apple seems to be more in favor of storyboard then writing lines of code, as per their WWDC videos. 根据他们的WWDC视频,苹果似乎更喜欢故事板,然后编写代码行。

As fellow developers do you still feel that writing everything out in code is the better way to go? 作为开发人员,您仍然觉得用代码编写所有内容是更好的方法吗? I hope to get a good few opinions on this as I want to see if my feelings on the matter are supported by your ideas, having done this for a longer period of time no doubt. 我希望能对此发表一些意见,因为我想看看我对这个问题的看法是否得到了你的想法的支持,毫无疑问,这已经做了很长时间了。

Thanks in advance. 提前致谢。

There are few advantages and disadvantages of both. 两者都没有什么优点和缺点。

Advantages of adding controls by Code 通过代码添加控件的优点

  • You can prefer writing everything to code if most of controls are dynamic. 如果大多数控件是动态的,则您可能更喜欢将所有内容编写为代码。 So that you can load controls whenever required. 这样您就可以在需要时加载控件。

  • Its easy to reuse code and make application more dynamic eg you want to make UI themes for application 它易于重用代码并使应用程序更加动态,例如,您想为应用程序创建UI主题

Advantages of Storyoard/ XIB Storyoard / XIB的优势

  • Using Storyboard/ XIB load all controls(Better if application is static) at once for that view you have to just bind properly. 使用情节提要/ XIB,一次加载该视图的所有控件(如果应用程序是静态的,则更好),您只需要正确绑定即可。

  • Design UI with storyboard/ XIB is easy as compare to code. 与代码相比,带有情节提要/ XIB的设计UI易于实现。

These are few advantages of both as per my understanding. 根据我的理解,这些都是很少的优点。

making application through the code, helps developer lot, it gives flexibility.but going through the storyboard decreases lines of code. 通过代码编写应用程序,可以帮助开发人员获得更多收益,并提供了灵活性。 for mobile application development decreased number of lines codes or less code is always welcome. 对于移动应用程序开发,总是欢迎减少行代码数量或减少代码数量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM