- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath不执行基本上只有3个原因

1. delegate没设,一定要有self.tableView.delegate = self

2. section,row的个数返回为0,或者有冲突

3. tableView的frame有问题,比如位(0,0,0,0)

我遇到的问题比较奇葩,因为我喜欢在代码里添加约束,所以都是先

initWithFrame:CGRectZero,然后添加约束。这样初始化tableView的时候它的frame为(0,0,0,0),所以不执行cellForRowAtIndexPath。

后来想了一些方法,总是有问题,后来发现:

添加的约束在viewDidLoad和viewWillAppear里都没有生效,只有在viewDidAppear里才生效,可能这就是代码添加约束的弊端。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath不执行的问题的更多相关文章

  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;方法意思

    这个方法是用来设置你的TableView中每一行显示的内容和格式的. indexPath 用来指示当前单元格,它的row方法可以获得这个单元格的行号,section方法可以获得这个单元格所处的区域号 ...

  2. UITableView中的(NSIndexPath *)indexPath

    indexPath 用来指示当前单元格,它的row方法可以获得这个单元格的行号,section方法可以获得这个单元格所处的区域号

  3. tableview 与 tableview cell

    1.tableview cell: import Foundationimport UIKit class CjwtCell: UITableViewCell { @IBOutlet var lb_c ...

  4. UITableViewCell嵌套UITableView的正确姿势

    内嵌UiTableView的高度计算起来太麻烦了,如何解决,就是把二级TableVIew里面的model item做到一级,然后对不同的item类型做不同的Cell,这样就Ok了.给一个得到Cell的 ...

  5. tableview: 实现tableview 的 section header 跟随tableview滑动

    方法一:(只有一个headerView)一段 如果你的tableview恰好只有一个headerView,实现这种效果就好办了.把要设置的headerView设置成tableView的header而不 ...

  6. [tableView dequeueReusableCellWithIdentifier:CellIdentifier] 后面forIndexPath:indexPath参数的解释

    解决以下错误: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'u ...

  7. UITableViewCell和UITableView的学习

    一:自定义UITableViewCell: 先来看UITableView.h: - (void)registerNib:(UINib *)nib forCellReuseIdentifier:(NSS ...

  8. ios uitableview button 获取cell indexpath.row

    在iOS7下面已经无效,因为iOS7的层级关系发生变化 UITableViewCell->UITableViewCellScrollView->UITableViewCellContent ...

  9. iOS UIKit:TableView之单元格配置(2)

    Table View是UITableView类的实例对象,其是使用节(section)来描述信息的一种滚动列表.但与普通的表格不同,tableView只有一行,且只能在垂直方向进行滚动.tableVi ...

随机推荐

  1. ruby 中文字符to_json后乱码(unicode)

    今天遇到一个中文to_json问题 text = "第1章 青豆 不要被外表骗了" text.to_json => "\"\\u7b2c1\\u7ae0 ...

  2. [转]VS2005/2008过期之后简单实用的升级方法

    网络上有不少key,但是用了之后没效果,发现了一个好方法可以解决.  把\vs\setup\下面的 setup.sdb文件用文本编辑器打开,然后改动其最后的一行([Product Key] 下面的一行 ...

  3. com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte

    com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte ...

  4. http协议客户端向服务器端请求时一般需要发送的内容

    out.println("GET /shopping/index.html HTTP/1.1");//请求行 包括请求方式,文件路径, http协议版本(必写)请求头.... ou ...

  5. codeforces A. Bayan Bus(简单模拟)

    #include <queue> #include <string> #include <cstdio> #include <cstring> #inc ...

  6. 基于 Markdown 的开源的 Node.js 知识库平台

    Raneto 是一个免费,开源的 Node.js 知识库平台,基于静态 Markdown 文件实现. Raneto 可以被称为静态网站生成器,因为它并不需要数据库支持.所有的内容都存储在 Markdo ...

  7. Java基础——事务

    一.事务 简单点说,事务就是一件事情.所有与事务相关的内容都是围绕这一件事情展开的. 二.事务的特性:ACID A:Atomicity(原子性),事务必须是一个不可分割的整体. C:Consisten ...

  8. myeclipse怎么github

    myeclipse怎么github 第一步.打开myeclipse->选择项目->鼠标右键->Team->Share project,将出现如下图所示: 第二步.选择git,在 ...

  9. 关于 getWriter() has already been called for this response 的错误解决办法

    java.lang.IllegalStateException: getWriter() has already been called for this response 今天在做显示图片的时候,( ...

  10. vs.net_2003 下载 虽然是老古董了,但还是很有用的。

    系统要求 支持的操作系统: Windows 2000; Windows NT; Windows Server 2003; Windows XP 以下VS2003的下载链接: http://bcsoft ...