这是我在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];
答案 0 :(得分:4)
请尝试此代码。收藏视图失去了我们的高度。
self.colView.alwaysBounceVertical = YES;
答案 1 :(得分:0)
您的代码看起来很好,只需要将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];
}