[英]Selector gets called in numberOfRowsInSection but not in cellForRowAtIndexPath
I have this code to fill a UITableView and the one returning the numberOfRowsInSection works fine. 我有这段代码可以填充UITableView,并且返回numberOfRowsInSection的代码可以正常工作。 The selector using appDelegate in the cellForRowAtIndexPath part is not called. 未调用cellForRowAtIndexPath部分中使用appDelegate的选择器。 Whats wrong here? 怎么了
- (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];
Methods are called. 方法被调用。 Selectors are (more or less) names of methods; 选择器(或多或少)是方法的名称; they are not called. 他们没有被召唤。
If -tableView:numberOfRowsInSection:
returns 0, there are no cells, so it doesn't call -tableView:cellForRowAtIndexPath:
. 如果-tableView:numberOfRowsInSection:
返回0,则没有单元格,因此它不会调用-tableView:cellForRowAtIndexPath:
Perhaps that part of the table isn't showing yet, and the UITableView is loading lazily. 也许表格的那部分尚未显示,并且UITableView延迟加载。 If so, scroll up so that those cells are visible and your delegate should be called. 如果是这样,请向上滚动以使那些单元格可见,并应调用您的委托。
tableView:numberOfRowsInSection: Does return 366 or similar so tableView:cellForRowAtIndexPath: gets called. tableView:numberOfRowsInSection:返回366或类似值,因此tableView:cellForRowAtIndexPath:被调用。 When I exchange the cell.textLabel.text to @"John Doe" it works just fine. 当我将cell.textLabel.text交换为@“ John Doe”时,它可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.