V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
satanwoo
V2EX  ›  iDev

大家不用 nib 开发 ios 界面的原因是啥?

  •  
  •   satanwoo · 2014-03-05 21:18:27 +08:00 · 5511 次点击
    这是一个创建于 3676 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我只是最近和很多人聊到了这个,
    原因如下:
    (1)有些人说nib的复用性不高。
    (2)有些人说nib只能开发静态初级的界面(比如关于,设置)
    (3)有些人说nib不好合作。我认为这个现在xcode5在修改过nib的文件内容后,其实已经大大简化了。
    (4) 最后点是我自己觉得的吧,读取nib是一次I/O操作,I/O可能会瓶颈吧。

    不知道大家怎么看
    29 条回复    2014-10-14 17:49:58 +08:00
    offspring
        1
    offspring  
       2014-03-05 21:25:02 +08:00
    大部分都是扯淡
    wezzard
        2
    wezzard  
       2014-03-05 21:27:04 +08:00
    大部分都是扯淡 +1
    ultragtx
        3
    ultragtx  
       2014-03-05 21:32:27 +08:00 via iPad   ❤️ 2
    1. nib要是复用性不高 手写的也一样
    2. 动态界面拆分开也都是一堆静态view 有什么用不了的
    3. xcode5 之后这个基本不是个问题
    4. 还不至于因为这个影响运行效率
    satanwoo
        4
    satanwoo  
    OP
       2014-03-05 21:35:41 +08:00
    @ultragtx 大神在这见到你了。
    satanwoo
        5
    satanwoo  
    OP
       2014-03-05 21:36:30 +08:00
    @ultragtx 我是看我同学写的ios app,然后今晚正好和他聊了这个话题。
    sobigfish
        6
    sobigfish  
       2014-03-05 21:52:13 +08:00
    @ultragtx
    @wezzard
    @offspring 请教下nib的多locale怎么做,直接在窗体上改很没效率啊。 谢谢
    ultragtx
        7
    ultragtx  
       2014-03-05 22:16:30 +08:00   ❤️ 1
    @sobigfish 有个这个 https://github.com/angelolloqui/AGi18n 不过我还没用过
    offspring
        8
    offspring  
       2014-03-06 00:07:10 +08:00
    ybh37
        9
    ybh37  
       2014-03-06 10:45:25 +08:00
    style的区别而已。
    xx314327475
        10
    xx314327475  
       2014-03-06 10:50:12 +08:00
    @offspring
    @wezzard
    @ybh37

    那么适配不同屏幕呢?
    ybh37
        11
    ybh37  
       2014-03-06 11:01:07 +08:00
    屏幕适配我没什么好办法,加判断生写的。
    offspring
        12
    offspring  
       2014-03-06 12:28:54 +08:00
    @xx314327475 autolayout
    xx314327475
        13
    xx314327475  
       2014-03-06 12:40:19 +08:00
    @offspring 曾经尝试过,无奈可能是我理解能力的问题,并没有很好的实践这个技术
    satanwoo
        14
    satanwoo  
    OP
       2014-03-06 12:57:20 +08:00
    @offspring
    @xx314327475
    autolayout效率低呢。能自己算resize自己调整是最高的。
    tgfbeta
        15
    tgfbeta  
       2014-03-06 14:39:31 +08:00
    只要保证一个人维护storyboard或者建立一个提交storyboard修改的约定,没啥不好的。
    tangqiaoboy
        16
    tangqiaoboy  
       2014-03-06 15:04:54 +08:00 via iPhone
    适度使用是可以的
    shiweifu
        17
    shiweifu  
       2014-03-06 16:19:24 +08:00
    offspring
        18
    offspring  
       2014-03-06 20:17:21 +08:00
    @satanwoo 苹果有必要推出个效率低的新东西么 autolayout是来源于Cassowary 已经被移植到各种平台 而且如果app是universal的 支持各种orientation 支持iOS6和iOS7 到时候iPhone6再出个新分辨率 你就resize到死吧
    satanwoo
        19
    satanwoo  
    OP
       2014-03-06 21:40:41 +08:00   ❤️ 1
    @offspring
    你急啥呢? 真难以想象你的回复如此气急败坏啊。。

    第一:苹果推出的东西不代表效率就高。autolayout是为了方便开发者针对适配,降低复杂度未必就能提升效率。况且我也没说绝对效率低,和自己手动判断改frame毫无疑问是低的。

    第二:就我写过的app来说,各种orientation本身就应该开发者自己判断,不然你觉得用代码写UI的意义在哪?如果一切都依靠本身机制,那我觉得写ios只要看什么ios 初级入门就够了。

    第三:现在universal 的app还多吗?

    第四:现在很多的设计都是列表式的设计,就算是关于界面这种静态的界面,你一个xib就能解决,你只要写一些UIView Category快速的帮助你更改下高度或者宽度不就行了?你全部用相对位置做我觉得是个基本功吧?
    jimneylee
        20
    jimneylee  
       2014-03-07 08:57:40 +08:00
    不擅长用xib的飘过,感觉还是要多用多比较。
    xib主要用于偏静态页面,类似dreamwear制作html页面,有一点可视化编程的思想在里面,通过查看xib文件,UI布局可读性增加了。
    如果是动态运行时变化比较多的话,还是建议代码编写,类似动画片和游戏的区别。
    chisj
        21
    chisj  
       2014-03-07 09:43:09 +08:00
    (4) 最后点是我自己觉得的吧,读取nib是一次I/O操作,I/O可能会瓶颈吧。

    ------->这想法有点迫害妄想症
    satanwoo
        22
    satanwoo  
    OP
       2014-03-07 10:11:17 +08:00
    @chisj
    是的。这是我一点乱猜的。。
    l6751902
        23
    l6751902  
       2014-03-07 10:30:07 +08:00
    习惯不习惯的问题而已,
    还有一个问题就是机器性能不行用interface builder很痛苦
    wupher
        24
    wupher  
       2014-03-07 11:16:11 +08:00
    就我个人而言,sb有些功能的实现上面可以少写和不写代码。
    BTW:OSX开发到现在仍然是只能支持XIB的。
    offspring
        25
    offspring  
       2014-03-07 15:14:52 +08:00
    @satanwoo 我哪里急了... 有可以降低复杂度的干嘛不用 而且universal的挺多的 你看evernote dropbox reeder等等不都是universal的么 而且我觉得如果没在真实的项目里使用过也不好意思说到底好不好用吧 就像有些人现在还不用ARC呢 他也能说出一堆道理
    clovelu
        26
    clovelu  
       2014-03-07 15:54:44 +08:00
    调试的时候代码要方便很多,比如调个背景颜色,如果是xib,你还得要进入到xib,找到对应view还调。来回却换非常痛苦。
    R0CKSTAR
        27
    R0CKSTAR  
       2014-04-10 14:46:14 +08:00
    SB/XIB + UISS(https://github.com/yeahdongcn/UISS) 很爽的
    问题就是多个人一块开发的时候merge很麻烦
    R0CKSTAR
        28
    R0CKSTAR  
       2014-04-11 09:39:56 +08:00
    Compilerrr
        29
    Compilerrr  
       2014-10-14 17:49:58 +08:00
    What we're doing is as follows:

    We're ignoring the iPad specific storyboard that Xcode sets up for us.

    We have a single storyboard for both iPad and iPhone. So far ALL the scenes are shared between them. If we need to create a custom scene for iPad at any point, we'll create a separate scene and give it an identifier with the suffix _iPad. Then we'll write code to load that at runtime. (The app uses a scheme where it instantiates view controllers from a descriptor file, and uses unique IDs instead of segues.)

    Storyboards are the wave of the future. Many of Apple's new tricks are built on storyboards, and don't work with XIBs, or are much harder to use with XIBs.

    As a simple example, iOS 6 has embed segues, which make it PAINLESS to create parent/child view controller relationships. Without that, you have a fair amount of rather fussy code to write. Certain view controllers like table view controllers pretty much have to be child view controllers (since a table view controller's root view is a table view, it doesn't lend itself to managing other UI elements)

    I put off learning storyboards for quite a while, and regret that I did.
    http://www.agileinfoways.com/technical-expertise/mobile-applications-development/iphone/

    Overall they are easier to use, enable new features, and are well worth it. I was productive with storyboards almost instantly.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5260 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 09:22 · PVG 17:22 · LAX 02:22 · JFK 05:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.