Objective c 一次显示一定数量的行,单击按钮,显示更多

Objective c 一次显示一定数量的行,单击按钮,显示更多,objective-c,ios,uitableview,loaddata,Objective C,Ios,Uitableview,Loaddata,我在这个问题上很吃力。我有一个NSArray*列表,其中包含plist文件中的70个元素。现在我需要将它们填充到UITableView。 我想要的是一次显示20个项目,然后单击第21个单元格显示另20个项目。。然后按第41个单元格显示另外20个项目。。。以此类推,直到72个细胞全部暴露 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { self.tableView.

我在这个问题上很吃力。我有一个NSArray*列表,其中包含plist文件中的70个元素。现在我需要将它们填充到UITableView。 我想要的是一次显示20个项目,然后单击第21个单元格显示另20个项目。。然后按第41个单元格显示另外20个项目。。。以此类推,直到72个细胞全部暴露

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    return 20;

}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath     *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

static NSString *addCellID = @"addMoreCell";
UITableViewCell *addCell = [tableView dequeueReusableCellWithIdentifier:addCellID];

if (indexPath.row == 0) {
    static NSString *CellIdentifier = @"labelCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    return cell;
} else if (indexPath.row < 25){
    NSDictionary *dic = [self.list objectAtIndex:indexPath.row];
    cell.textLabel.text = [dic objectForKey:@"Title"];
    cell.detailTextLabel.text = [dic objectForKey:@"Tips"];
    return cell;
} else {
    if (cell == nil) {
        addCell.textLabel.text = @"Load More...";
        return cell;
    }
}
}


- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == 20)
{
    [self.tableView reloadData];
}
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
返回20;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“cell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
静态NSString*addCellID=@“addMoreCell”;
UITableViewCell*addCell=[tableView dequeueReusableCellWithIdentifier:addCellID];
if(indexPath.row==0){
静态NSString*CellIdentifier=@“labelCell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
返回单元;
}else if(indexPath.row<25){
NSDictionary*dic=[self.list objectAtIndex:indexath.row];
cell.textlab.text=[dic objectForKey:@“Title”];
cell.detailTextLabel.text=[dic objectForKey:@“提示”];
返回单元;
}否则{
如果(单元格==nil){
addCell.textLabel.text=@“加载更多…”;
返回单元;
}
}
}
-(void)tableView:(UITableView*)tableView将显示单元格:(UITableViewCell*)用于rowatindexpath的单元格:(NSIndexPath*)indexPath
{
if(indexPath.row==20)
{
[self.tableView重载数据];
}
}

所以我做了类似的事情。您有一个包含70个字符串(或字典)的数组要显示在表中。“numberOfRowsInSection:”应使用初始设置为20的ivar


按下按钮后,将ivar增加20(但不超过实际数据量!),重新加载表格,然后可以使用tableView方法将表格向上滚动到“新”单元格。

因此我做了类似的操作。您有一个包含70个字符串(或字典)的数组要显示在表中。“numberOfRowsInSection:”应使用初始设置为20的ivar


按下按钮后,将ivar增加20(但不超过实际数据量!),重新加载表格,然后可以使用tableView方法将表格向上滚动到“新”单元格。

获取一个数组,在该数组中,您将从plist添加20个元素

设置
numberofrowsinssection=[array count]

检查plist中的
numberofrowsincreation
,如果小于,则
将numberofrowsincreation增加1。

在cellForRowAtIndexPath中 检查
if(indexPath.row


然后添加
“LoadMore Cell”
否则不添加。

获取一个数组,您将
从plist中添加20个元素,然后

设置
numberofrowsinssection=[array count]

检查plist中的
numberofrowsincreation
,如果小于,则
将numberofrowsincreation增加1。

在cellForRowAtIndexPath中 检查
if(indexPath.row


然后添加“加载更多单元格”
否则不添加。

查看UITableView部分查看UITableView部分我有类似的场景。我有一个包含76个对象(大约)的数组。填充tableview时,table一次只能显示10个单元格。首先是0-10个对象,然后按下“下一步”按钮表,应该显示11-20个数据,然后是21-30个数据,依此类推。。。那我怎么能这样呢?你知道这件事吗?我有类似的情况。我有一个包含76个对象(大约)的数组。填充tableview时,table一次只能显示10个单元格。首先是0-10个对象,然后按下“下一步”按钮表,应该显示11-20个数据,然后是21-30个数据,依此类推。。。那我怎么能这样呢?你对此有什么想法吗?