- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSLog(@"Test1");
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//#warning Incomplete method implementation.
// Return the number of rows in the section.
NSLog(@"No. of sections- %d",section);
return [[[BNRItemStore sharedStore] allItems] count] ;//no. of rows
}
在上述情況下,numberOfSectionsInTableView:
方法被調用兩次之前調用tableView方法。我不明白爲什麼。問題與numberOfSectionsInTableView方法
另一件令我迷惑的事情是,當我將1
作爲numberOfSectionsInTableView:
方法中的段數返回時,爲什麼它不反映在- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
方法中?它相當於將其記錄爲0
。
以前是否將段參數更新爲1
?我的意思是在運行時tableView:numberOfRowsInSection:
方法在內部被調用,所以顯然section
參數應該保持一定的值。
是不是這樣?
段數的計數從0開始,所以如果你聲明你只有一個段,它的索引將爲零。這就是爲什麼你在cellForRow中看到0節的原因 –