繁体   English   中英

当一个节有0行/项时,只有一个节的UITableView和UICollectionView不显示UIRefreshControl

[英]UITableView and UICollectionView with one section doesn't show UIRefreshControl when section have 0 rows / items

我有一个页面显示UITableViewUICollectionView (用户可以通过按钮在这两个元素之间切换)。 所有内容都显示在一个部分中。

正如我在标题中所写,当该部分具有0行(对于UITableView )或0个项目(对于UICollectionView )时,我将无法使用UIRefreshControl进行下拉刷新。

    self.tableViewRefreshControl = [[UIRefreshControl alloc] init];
    [self.tableViewRefreshControl addTarget:self action:@selector(didValueChangedTableViewRefreshControl) forControlEvents:UIControlEventValueChanged];
    [self.tableView addSubview:self.tableViewRefreshControl];

我该如何解决这个问题?

尝试一下(将其放入UITableViewController viewDidLoad中):

UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString: NSLocalizedString(@"Release to Refresh", nil)];

[refreshControl addTarget: self
                   action: @selector(refresh:)
         forControlEvents: UIControlEventValueChanged];

self.refreshControl = refreshControl;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM