簡體   English   中英

選擇器在numberOfRowsInSection中被調用,但不在cellForRowAtIndexPath中被調用

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM