更新时间:2023-12-02 18:20:46
tableView:numberOfRowsInSection:
是确定将显示多少行的方法,因此第一步将是更改。在视图控制器中还需要一个属性来跟踪应该显示多少行。类似这样:
tableView:numberOfRowsInSection:
is the method that determines how many rows will be shown, so the first step will be to change that. You also need a property in your view controller to keep track of how many rows should be visible. Something like this:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.numberOfRowsVisible;
}
当点击更多按钮时,必须增加该数字并重新加载tableView数据。
And when the more button is clicked, you have to increase that number and reload the tableView data.
-(void)moreButtonClickAction {
if (self.numberOfRowsVisible < self.maxNumberOfRows)
self.numberOfRowsVisible = MIN(self.numberOfRowsVisible + 10, self.maxRows);
[self.tableView reloadData];
}