0

像这样的功能:

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    NSLog(@"called")
    return 1;
}

没有被调用,因为日志没有出现在控制台上。我尝试使用

[table realoadData]

但它仍然不起作用

4

2 回答 2

3

确保将 UITableViewDataSource 和 UITableViewDelegate 设置为该方法所在的类

.h 
@interface class_name : UIViewController <UITableViewDelegate, UITableViewDataSource>
{ UITableView *tableView; }

.m
in the viewDidLoad (or any other loading method)

tableView.delegate = self;
tableView.dataSource = self;

如果你是 UITableViewController 的子类,它应该已经可以工作了

希望有帮助!

于 2014-02-18T01:25:30.413 回答
2
  1. 在 Nib 文件中,需要输出 tableview。
  2. 你的子类必须有 UITableViewDataSource 和 UITableViewDelegate。
  3. 分配 tableview.delegate = self 和 tableView.dataSource = self;
于 2014-02-18T03:12:35.573 回答