gpt4 book ai didi

ios - 如何暂停调用tableview的reloadData?

转载 作者:行者123 更新时间:2023-11-29 01:44:26 25 4
gpt4 key购买 nike

reloadDataviewDidLayoutSubviews 之后 NSLog 输出,

我希望tableview在GetDataSource之后调用reloadData,第一次加载时没有reloadData。我什至尝试设置 _tableView.dataSource = nil; 并将其设置为 self 在 GetDatasource();

但是 reloadDataGetDatasource(); 之前一直被调用GetDatasource(); 位于 viewDidload();

  viewWillAppar: <ATOMCutstomNavigationController: 0x1476abfc0>
viewDidload
viewWillAppear
viewWillAppear: <ATOMMyFollowViewController: 0x14751b4c0>
viewWillLayoutSubviews
viewDidLayoutSubviews
reloadData
viewWillLayoutSubviews
viewDidLayoutSubviews
viewDidAppear
GetDataSource()

有人有任何提示吗?我该如何暂停reloadData或者我犯了什么错误?

code In viewDidload:
    _myAttentionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NAV_HEIGHT - TAB_HEIGHT)];
self.view = _myAttentionView;
_tableView = [[RefreshTableView alloc] initWithFrame:_myAttentionView.bounds];
[_tableView registerClass:[kfcFollowCell class] forCellReuseIdentifier:CellIdentifier];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.estimatedRowHeight = SCREEN_HEIGHT - NAV_HEIGHT - TAB_HEIGHT;
_tableView.delegate = self;
_tableView.psDelegate = self;
_tableView.dataSource = nil;
[_myAttentionView addSubview:_tableView];
_tapMyAttentionGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapMyAttentionGesture:)];
[_tableView addGestureRecognizer:_tapMyAttentionGesture];
_canRefreshFooter = YES;
_dataSource = [NSMutableArray array];
[self firstGetDataSource];


- (void)getDataSource {

Model *sss = [ATOMShowAttention new];
[sss Get:param withBlock:^(NSMutableArray *resultArray, NSError *error) {
if (resultArray.count) {
[_dataSource removeAllObjects];
}
for (ATOMCommonImage *commonImage in resultArray) {
kfcFollowVM * viewModel = [kfcFollowVM new];
[viewModel setViewModelData:commonImage];
[_dataSource addObject:viewModel];
}
if (!_hasSetSource) {
_tableView.dataSource = self;
_hasSetSource = YES;
}
[_tableView reloadData];
[_tableView.header endRefreshing];
}];
}

最佳答案

在 View 中加载

_myAttentionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NAV_HEIGHT - TAB_HEIGHT)];
self.view = _myAttentionView;
_tableView = [[RefreshTableView alloc] initWithFrame:_myAttentionView.bounds];
_dataSource = [NSMutableArray array];//do it HERE..........
[self firstGetDataSource];//do it HERE...........
[_tableView registerClass:[kfcFollowCell class] forCellReuseIdentifier:CellIdentifier];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.estimatedRowHeight = SCREEN_HEIGHT - NAV_HEIGHT - TAB_HEIGHT;
_tableView.delegate = self;
_tableView.psDelegate = self;
_tableView.dataSource = nil;
[_myAttentionView addSubview:_tableView];
_tapMyAttentionGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapMyAttentionGesture:)];
[_tableView addGestureRecognizer:_tapMyAttentionGesture];
_canRefreshFooter = YES;

关于ios - 如何暂停调用tableview的reloadData?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32086224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com