[英]UICollectionView: Show label “No item” in the section that don't have any item
[英]UITableView and UICollectionView with one section doesn't show UIRefreshControl when section have 0 rows / items
我有一个页面显示UITableView
或UICollectionView
(用户可以通过按钮在这两个元素之间切换)。 所有内容都显示在一个部分中。
正如我在标题中所写,当该部分具有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.