[英]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.