首页 > 移动平台 > 详细

ios tableviewcontroller

时间:2015-03-22 17:56:10      阅读:310      评论:0      收藏:0      [点我收藏+]

    方法

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" forIndexPath:indexPath];

    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier"];

  之间的区别

下面是stack 里找到的答案

The most important difference is that the forIndexPath: version asserts (crashes) if you didn‘t register a class or nib for the identifier.  The older (non-forIndexPath:) version returns nil in that case.

You register a class for an identifier by sending registerClass:forCellReuseIdentifier: to the table view. You register a nib for an identifier by sending registerNib:forCellReuseIdentifier: to the table view.

If you create your table view and your cell prototypes in a storyboard, the storyboard loader takes care of registering the cell prototypes that you defined in the storyboard.

  如果没有注册一个class 或者 一个nib  , 使用 前者( forindexpath ) 会报错。

      技术分享

附上stackoverflow  链接  http://stackoverflow.com/questions/25826383/when-to-use-dequeuereusablecellwithidentifier-vs-dequeuereusablecellwithidentifi

http://stackoverflow.com/questions/12737860/assertion-failure-in-dequeuereusablecellwithidentifierforindexpath

ios tableviewcontroller

原文:http://www.cnblogs.com/stuwan/p/4357521.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!