在uitableviewcell中制作"加载更多"按钮?

Tus*_*ani 12 cocoa-touch objective-c uitableview ios4

嘿,任何人都可以指导我通过这个我在表中有大约15个条目我希望另外15个在最后一个UITableViewCell中提出更多的负载.谁能帮助我?

Sri*_*iya 19

在tableview中显示一个额外的行

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return dataRows+1;
    }
Run Code Online (Sandbox Code Playgroud)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

        //after setting tableviewcell

        if(indexPath.row==dataRows){

        cell.textLabel.text=@"Load More Rows";
        }
    }
Run Code Online (Sandbox Code Playgroud)

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {

    if(indexPath.row==dataRows){
    //there you can write code to get next rows
    }
 }
Run Code Online (Sandbox Code Playgroud)

您需要根据显示的行更新numberOfRows变量.

编辑:获取额外条目后,可以使用以下方法将它们添加到现有条目数组中.您的原始数组应该是NSMutableArray使用此方法.

[originalEntriesArray addObjectsFromArray:extraEntriesArray];


Abi*_*ern 8

我写了一个这样做的示例项目.从GitHub https://github.com/Abizern/PartialTable下载