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
Keita1314
V2EX  ›  iDev

如何动态地根据 json/xml 的描述来实现自定义 UITableViewCell?

  •  1
     
  •   Keita1314 · Dec 27, 2015 · 2754 views
    This topic created in 3815 days ago, the information mentioned may be changed or developed.

    一个 APP 里面有多个项目,一个项目对应着一个 UITableView,不同的项目有不同的 json/xml,这里 json/xml 是用来描述 UITableViewCell ,然后切换项目的时候根据 json/xml 来渲染 UITableViewCell.
    比如
    一个项目的 cell 可能是这样

    {
    "cell":{
    "a":1
    "c":2
    }
    }

    另一个项目可能是这样

    {
    "cell":{
    "d":2
    "f":4
    "g":1
    "h":1
    }
    }

    只涉及文字, cell 要展示的内容要完全依赖项目对应的 json/xml 的,应该怎么实现这个自定义 UITableViewCell ?

    8 replies    2015-12-28 08:56:41 +08:00
    Keita1314
        1
    Keita1314  
    OP
       Dec 27, 2015
    @onevcat 邀请喵神~
    Sunnyyoung
        2
    Sunnyyoung  
       Dec 27, 2015 via iPhone
    好奇 b 和 e 去哪了
    Keita1314
        3
    Keita1314  
    OP
       Dec 27, 2015
    @Sunnyyoung 举例子而已,实际的意思就是 tableviewcell 里面的内容,比如标签有哪些,有多少个,是根据 json/xml 来获取的,我想了想感觉只有在 cellForRowAtIndexPath 里面动态加 view ,但又觉得这种效率会不会太低
    Sunnyyoung
        4
    Sunnyyoung  
       Dec 27, 2015 via iPhone
    @Keita1314 不知道你要渲染的内容仅仅是文字呢还是复杂的内容
    felixzhu
        5
    felixzhu  
       Dec 27, 2015
    类似 NimbusKit 的实现?
    Sunnyyoung
        6
    Sunnyyoung  
       Dec 27, 2015 via iPhone
    诶,楼主你的头像跟我的好配,哈哈
    txx
        7
    txx  
       Dec 27, 2015 via iPhone
    写一个渲染引擎啦...
    clangdiagnostic
        8
    clangdiagnostic  
       Dec 28, 2015   ❤️ 1
    ViewModel 可能是你需要的,在 ViewModel 中处理不同的 json/xml 产生的内容。当然了,这是在你的 Cell 的 View 是不变的情况下。需要变化的话还是不同项目分开写把。其他的方法看着都觉得麻烦
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2675 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 11:14 · PVG 19:14 · LAX 04:14 · JFK 07:14
    ♥ Do have faith in what you're doing.