2010-11-22 15 views
1

このコードはUITableViewを満たすために用意されており、numberOfRowsInSectionを返すものは正常に動作します。 cellForRowAtIndexPath部分のappDelegateを使用するセレクタは呼び出されません。ここで何が間違っていますか?セレクタはnumberOfRowsInSectionで呼び出されますが、cellForRowAtIndexPathでは呼び出されません

+0

appDelegate.namesForDay.countの値は何ですか?これが0の場合、cellForRowAtIndexPathは呼び出されません。 – Krishnan

答えて

1
- (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]; 

は、おそらくテーブルの一部がまだ表示されていない、とのUITableViewをレイジーにロードされます。その場合は、スクロールアップしてそのセルが表示され、代理人が呼び出されるようにします。

6

メソッドが呼び出されます。セレクタはメソッドの名前です(多かれ少なかれ)。彼らは呼ばれません。

-tableView:numberOfRowsInSection:場合は0を返しますが、何の細胞が存在しないので、-tableView:cellForRowAtIndexPath:を呼び出すことはありません。

+0

ありがとうございます。ついに私の問題が見つかりました! –

0

のtableView:numberOfRowsInSection:そうのtableViewを366または類似を返すん:cellForRowAtIndexPath:呼び出されます。私がcell.textLabel.textを@ "John Doe"と交換すると、うまく動作します。

関連する問題