ios - UITableView 上拉刷新 加载数据问题?
PHP中文网
PHP中文网 2017-04-17 14:54:09
[iOS讨论组]
@property (strong, nonatomic) NSMutableArary *listArray;


#pragma mark - TableView datasource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    static NSString *CellIdentifier = @"ListTableViewCell";
    NewTab2TableViewCell *cell = (NewTab2TableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if(cell == nil)
    {
        NSArray *nibs=[[NSBundle mainBundle] loadNibNamed:@"NewTab2TableViewCell" owner:self options:nil];
        cell = (NewTab2TableViewCell *)[nibs objectAtIndex:0];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        [cell setValue:CellIdentifier forKey:@"reuseIdentifier"];

    }

    //**遍历respont**//
    NSMutableDictionary *tempDic = [listArray objectAtIndex:indexPath.row];
    NSLog(@"tempDic = %@", tempDic);

    cell.timeLabel.text = [NSString stringWithFormat:@"%@", [tempDic objectForKey:@"bno"]];  // 时间

    return cell;
}


这里面listArray的数据是AFNetworking-POST请求的。


[manager POST:encodedUrl parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {

第一次请求返回的JSON,responseObject,是有10个这种的


然后我有个上拉刷新

[_tableView addLegendFooterWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];

- (void)loadMoreData
{
// 代码省略
    [manager POST:encodedUrl parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"JSON_上拉刷新 : %@", responseObject);

}

上拉刷新继续返回10个数据,我想问的是在tableView的cellForRowAtIndexPath方法里,怎样把刷新后得到的新十个数据刷到tableview里面。也就是说tableview里有20个数据。

PHP中文网
PHP中文网

认证高级PHP讲师

全部回复(2)
天蓬老师
[tableView reloadData]
PHP中文网

[_tableView addLegendFooterWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];

楼主你能把省略的代码发出来吗?

  • (void)loadMoreData
    {

// 代码省略

[manager POST:encodedUrl parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"JSON_上拉刷新 : %@", responseObject);

}

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号