简体   繁体   English

选择器在numberOfRowsInSection中被调用,但不在cellForRowAtIndexPath中被调用

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

相关问题 cellForRowAtIndexPath:被立即调用,而numberOfRowsInSection:不被调用 - cellForRowAtIndexPath: being called immediately while numberOfRowsInSection: is not called 在Apple的MultipleDetailViews示例中调用numberOfRowsInSection但不调用cellForRowAtIndexPath - numberOfRowsInSection called but not cellForRowAtIndexPath in MultipleDetailViews sample of apple iOS:在numberOfRowsInSection之后没有立即调用cellForRowAtIndexPath - iOS: cellForRowAtIndexPath not being called immediately after numberOfRowsInSection CellForRowAtIndexPath被意外调用 - CellForRowAtIndexPath gets called unexpectedly 在调用 reloadData 时调用 numberOfRowsInSection 后有时不调用 cellForRowAtIndexPath - cellForRowAtIndexPath is not called sometimes after calling numberOfRowsInSection on calling reloadData cellForRowAtIndexPath:被调用但没有显示在tableview中 - cellForRowAtIndexPath: gets called but nothing shows up in tableview cellForRowAtIndexPath:未调用 - cellForRowAtIndexPath: not called 我们如何将 numberOfRowsInSection 同步到 cellForRowAtIndexPath? - How do we sync numberOfRowsInSection to cellForRowAtIndexPath? numberOfRowsInSection:未在 reloadData 上调用 - numberOfRowsInSection: not called on reloadData 没有为UITableView调用numberOfRowsInSection - numberOfRowsInSection not being called for UITableView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM