如何在uiscrollview上面添加mj下拉刷新
展开全部
给UICollectionView添加下拉刷新
_collectionV.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
}];
然后在- (void)scrollViewDidScroll:(UIScrollView *)scrollView代理中根据contentOffset的变化,在_collectionV往上拉时,设置导航栏也跟着上提,出现问题
1.如果设置
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 ) {
self.automaticallyAdjustsScrollViewInsets = NO;
self.edgesForExtendedLayout = UIRectEdgeNone;
}
下拉刷新后_collectionV和导航栏间会有一段黑色空白,如附图所示
2.如果设置_collectionV的偏移
if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) {
self.automaticallyAdjustsScrollViewInsets = NO;
UIEdgeInsets insets = self.collectionV.contentInset;
insets.top = self.navigationController.navigationBar.bounds.size.height +
[UIApplication sharedApplication].statusBarFrame.size.height;
self.collectionV.contentInset = insets;
self.collectionV.scrollIndicatorInsets = insets;
}
_collectionV.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
}];
然后在- (void)scrollViewDidScroll:(UIScrollView *)scrollView代理中根据contentOffset的变化,在_collectionV往上拉时,设置导航栏也跟着上提,出现问题
1.如果设置
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 ) {
self.automaticallyAdjustsScrollViewInsets = NO;
self.edgesForExtendedLayout = UIRectEdgeNone;
}
下拉刷新后_collectionV和导航栏间会有一段黑色空白,如附图所示
2.如果设置_collectionV的偏移
if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) {
self.automaticallyAdjustsScrollViewInsets = NO;
UIEdgeInsets insets = self.collectionV.contentInset;
insets.top = self.navigationController.navigationBar.bounds.size.height +
[UIApplication sharedApplication].statusBarFrame.size.height;
self.collectionV.contentInset = insets;
self.collectionV.scrollIndicatorInsets = insets;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询