Objective c 未填充UITableView,因为从未调用tableView:cellForRowAtIndexPath

Objective c 未填充UITableView,因为从未调用tableView:cellForRowAtIndexPath,objective-c,ios,Objective C,Ios,未填充My UITableView,因为: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 永远不会调用 以下是初始化表的方式: self.recentScannedItems = [[[UITableView alloc] initWithFrame:kLastScannedPortrait style:UITableViewStyle

未填充My UITableView,因为:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
永远不会调用

以下是初始化表的方式:

self.recentScannedItems = [[[UITableView alloc] initWithFrame:kLastScannedPortrait style:UITableViewStylePlain] autorelease];
    [self.recentScannedItems setDelegate:self];
    [self.recentScannedItems setDataSource:self];
    [self.view addSubview:recentScannedItems];
我缺少什么?

您的类是否符合UITableViewDataSource?比如:


您是否正确实现了数据源方法:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
    // Return the number of sections.
    return NumberOfSections;
}

- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.

    return NumberOfRows;
}

如果未实现此方法,或者在其中返回0,则不会调用cellForRowAtIndexPath

从NumberOfRowInSection:返回什么?是否确定最近扫描的项目包含某些内容。。。很可能它从未被调用过,因为numberofrowsinssection:返回0个计数元素。是的,它符合它。顺便说一句,这只是为了编译器,它应该可以工作,即使它丢失了,我相信。还没有解决。。。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
    // Return the number of sections.
    return NumberOfSections;
}

- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.

    return NumberOfRows;
}