简体   繁体   English

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

[英]UITableView is not populated because tableView:cellForRowAtIndexPath is never invoked

My UITableView is not populated because: 未填充我的UITableView,因为:

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

is never invoked. 永远不会被调用。

This is how I initialize the table: 这是我初始化表的方式:

self.recentScannedItems = [[[UITableView alloc] initWithFrame:kLastScannedPortrait style:UITableViewStylePlain] autorelease];
    [self.recentScannedItems setDelegate:self];
    [self.recentScannedItems setDataSource:self];
    [self.view addSubview:recentScannedItems];

what am I missing ? 我想念什么?

Does your class comply to UITableViewDataSource ? 您的课程符合UITableViewDataSource吗? Like: 喜欢:

@interface mySuperClass : UIViewController <UITableViewDataSource, UITableViewDelegate>

Have you implemented correctly the datasource methods: 您是否正确实现了数据源方法:

- (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;
}

If you are not implementing this methods, or if you are returning 0 in them, cellForRowAtIndexPath won't be called 如果未实现此方法,或者在其中返回0,则不会调用cellForRowAtIndexPath

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 tableview:cellForRowAtIndexPath从未调用 - tableview:cellForRowAtIndexPath never called 永远不会调用UITableView cellForRowAtIndexPath - UITableView cellForRowAtIndexPath never called tableView:cellForRowAtIndexPath:永远不会被调用 - tableView:cellForRowAtIndexPath: never being called UITableView tableView:cellForRowAtIndexPath:没有被调用 - UITableView tableView:cellForRowAtIndexPath: not getting called tableView:cellForRowAtIndexPath:因为数组为空而不被调用? - tableView:cellForRowAtIndexPath: not called because array is empty? 未调用UITableView更新器函数((UITableview)tableview cellForRowAtIndexPath) - UITableView updater function not being called ( (UITableview) tableview cellForRowAtIndexPath ) 原因:“ UITableView数据源必须从tableView:cellForRowAtIndexPath返回单元格 - reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath UITableView数据源必须从tableView:cellForRowAtIndexPath返回一个单元格: - UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath: UITableView dataSource必须从tableView:cellForRowAtIndexPath返回一个单元格 - UITableView dataSource must return a cell from tableView: cellForRowAtIndexPath 'UITableView dataSource 必须从 tableView 返回一个单元格:cellForRowAtIndexPath:' - 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM