我已经实现了一个视图控制器,它带有一个名为 ligatable 的表视图控件。这个表视图在一个名为 ligaViewController.h 的表视图控制器中有它的委托。表格视图控件已经实现了一个原型单元,它设置了 ligaCell.h 控制器。以下是详细信息:
competicionViewController.h
#import "ligaViewController.h"
@interface CompeticionViewController : UIViewController
{
IBOutlet UITableView *ligaTable;
ligaViewController *ligaController;
}
@property (strong, nonatomic) IBOutlet UITableView *ligaTable;
@property (strong, nonatomic) ligaViewController *ligaController;
competicionViewController.h
- (void)viewDidLoad
{
...
ligaController = [[ligaViewController alloc] init];
[ligaTable setDelegate:ligaController];
[ligaTable setDataSource:ligaController];
....
以及 ligaViewController 中的委托方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ligaCell *cell = [self.tableView
dequeueReusableCellWithIdentifier:@"posicion"];
NSDictionary *posicion = [[NSDictionary alloc] initWithDictionary: [ligaArray objectAtIndex:indexPath.row]];
cell.posicion.text = [posicion valueForKey:@"posicion"];
cell.PJ.text = [posicion valueForKey:@"pj"];
cell.PG.text = [posicion valueForKey:@"pg"];
cell.PP.text = [posicion valueForKey:@"pp"];
cell.PF.text = [posicion valueForKey:@"favor"];
cell.PC.text = [posicion valueForKey:@"contra"];
return cell;
}
它目前给我这个错误:
terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
非常感谢