加载一级分类数据、加载即选中第一行

来源:互联网 发布:人工智能5分钟演讲稿 编辑:程序博客网 时间:2024/05/22 02:29




- (void)loadData {

    

    [SCCatelogListTool GETCatelogyListWithLevel:@"0" catelogyId:@"0" success:^(NSArray *catelogyList) {


        [self.catelogyList addObjectsFromArray:catelogyList];

        // 注意:得到数据后,一定要刷新列表

        [self.tableView reloadData];

        

        // 加载即选中第一行

        if (self.catelogyList.count) {

            

            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];

            [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionTop];

            [self tableView:self.tableView didSelectRowAtIndexPath:indexPath];

        }

        

    } failure:^(NSError *error) {

        SCLog(@"请求分类信息出错:%@", error);

    }];

}


0 0
原创粉丝点击