为什么cellForRowAtIndexPath方法不调用?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

没有被调用的原因可能是数据源中没有数据!

注意这几个相关方法的调用顺序是:
1、先调用numberOfSectionsInTableView

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;

当有数据时才会往下进行,才会调用方法:tableView:cellForRowAtIndexPath;

2、当numberOfSectionsInTableView不为0时说明有数据,这时才会获取每个section中的numberOfRows

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

猜你喜欢

转载自blog.csdn.net/fanyong245758753/article/details/58139041