![](/img/trans.png)
[英]cellForRowAtIndexPath: being called immediately while numberOfRowsInSection: is not called
[英]Selector gets called in numberOfRowsInSection but not in cellForRowAtIndexPath
我有这段代码可以填充UITableView,并且返回numberOfRowsInSection的代码可以正常工作。 未调用cellForRowAtIndexPath部分中使用appDelegate的选择器。 怎么了
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
VIP_GeburtstagAppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate getEntriesForDate:section];
return appDelegate.namesForDay.count;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
VIP_GeburtstagAppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate getEntriesForDate:indexPath.section];
方法被调用。 选择器(或多或少)是方法的名称; 他们没有被召唤。
如果-tableView:numberOfRowsInSection:
返回0,则没有单元格,因此它不会调用-tableView:cellForRowAtIndexPath:
也许表格的那部分尚未显示,并且UITableView延迟加载。 如果是这样,请向上滚动以使那些单元格可见,并应调用您的委托。
tableView:numberOfRowsInSection:返回366或类似值,因此tableView:cellForRowAtIndexPath:被调用。 当我将cell.textLabel.text交换为@“ John Doe”时,它可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.