gpt4 book ai didi

ios - 刷新后 UIRefreshControl 未隐藏。 iOS

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:22:02 25 4
gpt4 key购买 nike

我在 TableView 中使用 UIRefreshControl。我在 viewDidLoad 中启动了刷新控制:

    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
[self.bestDealsTableView addSubview:self.refreshControl];

我有一个滚动的目标方法:

-(void) handleRefresh:(UIRefreshControl *) refreshControl{
[self performSelector:@selector(updateDealsList) withObject:nil withObject:nil];
}

updateDealsList 方法:

- (void) updateDealsList {
self.dealsService = [[BestDealsService alloc] initServiceWithDelegate:self isLocalCall:NO];
[self.dealsService fetchBestDeals];
}

在我的服务响应方式中:

    [self.refreshControl endRefreshing];
self.isTableViewInRefreshMode = YES;
[self.bestDealsTableView reloadData];

现在,我有两个问题:1. 我的刷新控件没有隐藏在我的服务的成功响应中。2. 如果我向下拉 TableView ,我可以看到一个刷新控件,但如果我再次向下滚动,我会看到一个新控件位于前一个控件的下方。

第一次刷新控制的图片:

enter image description here

这里,再次向下滚动后:

enter image description here注意:我使用的是自定义 TableViewCell

最佳答案

我是这样解决的:

// Pull To Refresh Code
if(self.refreshControl == nil){
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
}
[self.myTableView addSubview:self.refreshControl];

关于ios - 刷新后 UIRefreshControl 未隐藏。 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23730185/

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