[英]pull to refresh not working in collection view when collection view have no data in ios
這是我在worldview方法中的刷新控件。
self.colView.refreshControl = [[UIRefreshControl alloc] init];
self.colView.refreshControl.backgroundColor = [UIColor purpleColor];
self.colView.refreshControl.tintColor = [UIColor whiteColor];
[self.colView.refreshControl addTarget:self
action:@selector(refresh)
forControlEvents:UIControlEventValueChanged];
請嘗試此代碼。 集合視圖失去了我們的高度。
self.colView.alwaysBounceVertical = YES;
您的代碼看起來不錯,只是您必須將tableview移到頂部並設置一些框架,然后再將其添加到collectionview。 即使您的集合視圖內容視圖的框架大小為0,這也將起作用:
-(void)addPullToRefressToTableView {
UIView *refreshView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, 0, 0)];
[self.tableView insertSubview:refreshView atIndex:0];
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.tintColor = [UIColor grayColor];
[refreshControl addTarget:self action:@selector(reloadDatas) forControlEvents:UIControlEventValueChanged];
NSMutableAttributedString *refreshString = [[NSMutableAttributedString alloc] initWithString:@"Pull To Refresh"];
[refreshView addSubview:refreshControl];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.