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

创建自定义的UITableViewCell时,设置IBOutlet应该是连接到UITableViewCell本身,而不是File's owner,为什么?

  •  
  •   qichunren ·
    qichunren · 2012-07-09 12:56:43 +08:00 · 5089 次点击
    这是一个创建于 4302 天前的主题,其中的信息可能已经有所发展或是发生改变。
    一般情况下,对于一个ViewController的xib的File's owner角色,我可以理解,都是将File's owner中的outlet连接到控件上的,但是为什么在创建一个自定义的UITableViewCell时,为什么必须得将UITableViewCell的outlet连接上控件上(UILabel,UIImageView等),而不是从File's owner上拖连接?否则会出现这样的错误提示信息:

    This class is not key value coding-compliant for the key namelabel.

    在youtube的这个教学视频中(第11分钟左右), 那个老外也遇到这个问题,卡住了一阵子,然后终于找到解决办法了。但是他怎么解释的我没听明白。
    4 条回复    1970-01-01 08:00:00 +08:00
    xuan_lengyue
        1
    xuan_lengyue  
       2012-07-09 12:57:35 +08:00
    我也发现了,不知道为什么
    kejinlu
        2
    kejinlu  
       2012-07-11 11:30:34 +08:00
    你应该自己建一个测试项目,然后把项目上传,方便别人帮你看。
    levey
        3
    levey  
       2012-07-11 14:23:41 +08:00
    你总要先看下File's owner是什么。。。。
    Biscuits
        4
    Biscuits  
       2014-03-12 00:25:33 +08:00
    https://youtube.googleapis.com/v/d_kO-J3DYvc?fs=1&hl=en_US
    应该绑定的是cell而不是file's owner,owner没包涵任何东西。
    - (NSArray *)loadNibNamed:(NSString *)name owner:(id)owner options:(NSDictionary *)options;
    调用这个方法的参数应该和定义的file's owner一致。要是不一致会找不到对应的key。
    我遇到是这样的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2061 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 00:02 · PVG 08:02 · LAX 17:02 · JFK 20:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.