2010-11-22 4 views
1

이 코드는 UITableView를 채울 수 있으며 numberOfRowsInSection을 반환하는 코드는 정상적으로 작동합니다. cellForRowAtIndexPath 부분에서 appDelegate를 사용하는 선택기가 호출되지 않습니다. 여기서 뭐가 틀린거야?Selector가 numberOfRowsInSection에서 호출되지만 cellForRowAtIndexPath에서는 호출되지 않습니다.

- (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]; 
+0

appDelegate.namesForDay.count의 값은 무엇입니까? 이 값이 0이면 cellForRowAtIndexPath가 호출되지 않습니다. – Krishnan

답변

1

아마도 테이블의 해당 부분이 표시되지 않고 UITableView가 지연되고 있습니다. 그렇다면 스크롤 업하여 해당 셀을 볼 수 있도록하고 대리인을 호출해야합니다.

6

메서드가 호출됩니다. 선택자는 (다소간) 메소드 이름입니다. 그들은 불리지 않는다.

-tableView:numberOfRowsInSection:이 0을 반환하면 셀이 없으므로 -tableView:cellForRowAtIndexPath:을 호출하지 않습니다.

+0

감사. 나는 마침내 내 문제를 발견! –

0

tableView : numberOfRowsInSection : 366 또는 그와 비슷한 값이 반환되므로 tableView : cellForRowAtIndexPath :가 호출됩니다. cell.textLabel.text를 @ "John Doe"와 교환하면 잘 작동합니다.

관련 문제