TableView的cellForRowAtIndexPath不执行,不过NumberofRow这个函数返回的值是正确的,包括NumberofSections的值也没问题。
我用的是Storyboard, 自己定义的TableView,
能执行到 NumberofRow, 就是不执行cellForRow! 
在xcode4中 xib下是没问题的
我在xcode5中用了Storyboard, 代码是一样的, 包括定义的也都是一样的, 结果不显示! 是不是有什么绑定我没做到? ViewController.h:@interface ViewController : UIViewController
<UITableViewDataSource, UITableViewDelegate>
@property (copy, nonatomic) NSMutableArray *prjlist;
@property (nonatomic, strong) UITableView *mytable;
.m
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{    return [self.prjlist count];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    NSLog(@"%i", self.prjlist.count); //能执行到,值正确
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //不执行
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }    NSMutableDictionary *prjinfo = self.prjlist[indexPath.row];    cell.textLabel.text = [prjinfo objectForKey:@"prj_name"];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;}

解决方案 »

  1.   

    storyboard 里delegate设置了没.我的博客 蓝天笔记 http://ubluesky.com/thankU.htm
      

  2.   

    就是在头文件里的
    ViewController.h:@interface ViewController : UIViewController
    <UITableViewDataSource, UITableViewDelegate>
      

  3.   

    你在storyboard 操作了?
    要拖一下的。
    要不他哪知道是哪个tableview要用啊。
      

  4.   

    我是自己定义的tableview 
    UITableView *mytable我在storyboard里拖到哪里呢?
      

  5.   

    - (void)viewDidLoad
    {
         
    self. mytable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
        self. mytable.separatorStyle = UITableViewCellSeparatorStyleNone;
        self. mytable.delegate = self;
        self. mytable.dataSource = self;

    ...
    }
      

  6.   

    这个也设置过了的我用的mknetworkkit获取的数据
    因为是异步的, 所以我用了 [self.mytable reloadData]在xcode4下, reload数据就出来了
    在xcode5下面 就不显示了
      

  7.   

    storyBorad中需要手动连接代理,关联viewController还有indefinitely,你看看都有操作么,有的话,看看是不是关联错地方了
      

  8.   

    1.设置代理 self.mytable.delegate = self;
                          self.mytable.dataSource = self;
    2.UI处理只能在主线程, [self.mytable reloadData]需要在主线程执行
      

  9.   

    楼主解决了吗?我的也不执行tableView: cellForRowAtIndexPath: 方法,楼主解决了吗
      

  10.   

    解决了,我只实现了
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    没有实现
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    粗心。
    实现numberofRowsInSection就会调用cellForRowAtIndexPath了,当然前提是你storyBoard里把tableView控件的datasource和delegate连上你的viewcontroler
      

  11.   


    swift里面numberofRowsInSection这个方法是可选的啊,不实现也可以运行cellForRowAtIndexPath代理