- (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节的原因 –