wxgbridgeq / swiftpulltorefresh Goto Github PK
View Code? Open in Web Editor NEWAn easy way to implement pull-to-refresh feature based on UIScrollView extension, written in Swift 4.
License: MIT License
An easy way to implement pull-to-refresh feature based on UIScrollView extension, written in Swift 4.
License: MIT License
How do I change the Indicator Header color?
你新添加的,去除上拉加载的就是spr_endRefreshingWithNoMoreData这个方法吧,我试过了,并不能去除上啦加载呀?
self.tableView?.spr_setIndicatorFooter { [weak self] in
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 2, execute: {
YJDebugPrint("上啦加载更多")
self?.tableView?.spr_endRefreshing()
})
}
self.tableView?.spr_endRefreshingWithNoMoreData()
就像这样,仅仅添加,然后马上删除,也还是有上拉加载
Here is the current situation:
I have 2 tabs, and each has a UITableView using SwiftPulltoRefresh. In my case I am using a custom header but int shouldn't matter. You will notice that on the second UITableView created the pull to refresh won't work. The animation still happens but the refresh completion handler is never called. Also sometimes the content insets and offset are not properly reset.
This is because every instance of a scrollview points to the same header.
In UIScrollView+Extensions.swift you define:
private var headerKey: UInt8 = 0
Every time you reference spr_header you call objc_getAssociatedObject with the exact same key.
My quick and dirty solution was to define headerKey as:
private var headerKey: UInt32 = 0
and in spr_setCustomHeader:
public func spr_setCustomHeader(_ header: RefreshView) {
headerKey = UInt32(arc4random())
self.spr_header = header
}
Now each scrollview has a unique key for each header and there are no more issues. You need to do this for footerKey and tempFooterKey as well.
Hello! I've been noticing a small bug when using SwiftPullToRefresh together with a navigation bar and a tab bar on iOS 11 or higher (works fine on iOS 10).
The indicator arrow doesn't seem to animate at the correct height.
Here's a video comparison between iOS 10 and iOS 11 behavior.
And here's the sample project.
Thanks for your help.
Loading indicator color cannot be changed ! I don't want custom header i just want to change the default color of loading indicator
不论是下拉,还是上拉都会出现这样的情况。
Would be nice to have left and right sided refresh, for example for UIPageviewcontroller
It works well on iOS 11.3, but failed on 10.3.3 with logs:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x19be2e10 of class UIScrollViewPanGestureRecognizer was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x19a8cef0> (
<NSKeyValueObservance 0x17f6c4d0: Observer: 0x17fa5550, Key path: state, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x17f60500>
<NSKeyValueObservance 0x19ab9180: Observer: 0x19a1d950, Key path: state, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x17f60500>
)'
I guess problem happen when you didn't remove observer in RefreshView.
Hello! I noticed this bug in iOS 13 where the arrow indicator stays in front of the search bar when using a UISearchController inside a UINavigationController. See screenshot here:
Sample project can be downloaded here. Thanks for your help
您好,如果我希望在加载更多完毕的时候,如果没有数据了,会在底部显示「已加载全部数据」,这能支持吗?
Class used RefreshView:
import SwiftPullToRefresh
import MaterialComponents
final class KZFooter: RefreshView {
private var loader: MDCActivityIndicator!
override public init(style: Style, height: CGFloat, action: @escaping () -> Void) {
loader = MDCActivityIndicator(frame: CGRect(x: 0, y: 0, width: 32, height: 32))
loader.cycleColors = [UIColor.dcmBrightLightBlue]
loader.radius = 15
super.init(style: style, height: height, action: action)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func didUpdateState(_ isRefreshing: Bool) {
if isRefreshing {
addSubview(loader)
loader.center = CGPoint(x: frame.width / 2, y: frame.height / 2)
loader.startAnimating()
} else {
loader.removeFromSuperview()
loader.stopAnimating()
}
}
override func didUpdateProgress(_ progress: CGFloat) {
}
}
Where I use this class:
final class CurrentVC : UIViewController {
var viewModel: CurrentVM!
var footer: KZFooter!
var header: KZFooter!
@IBOutlet weak var table: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
footer = KZFooter(style: .autoFooter, height: 57) { [weak self] in
guard let sself = self else { return }
sself.viewModel!.loadNextPage.next(())
}
table.spr_setCustomFooter(footer)
header = KZFooter(style: .header, height: 57) { [weak self] in
guard let sself = self else { return }
sself.viewModel!.refresh.next(())
}
table.spr_setCustomHeader(header)
}
}
It don't deallocate and every time I reopen screen it create more instances of KZFooter
Any ideas how to fix that
:(
i have problem that header view not appear
在很多情况下,比如上啦加载更多,一开始有,后来全部数据加载完了,就要移除刷新控件,你少写了个移除方法(或者我看漏了哪个文件,没找到),可以添加一下嘛,谢谢啦😀
scrollView.spr_addIndicatorFooter { [weak self] in // do your action here // self?.scrollView.spr_endRefreshing() }
我使用spr_addIndicatorFooter给UITableView添加了一个上拉加载控件,但是点击cell时 didSelectRowAt 不再响应?我把添加IndicatorFooter相关代码注释后一切正常,请问是bug,还是我代码问题?
spr_endRefreshingWithNoMoreData之后如何重置呢
layer.strokeColor = UIColor.label.withAlphaComponent(0.8).cgColor
This repo needs to provide a privacy manifest, as described here: https://developer.apple.com/news/?id=av1nevon, thank a lot.
ScrollViewExtension.swift里的结构体Default报错
Struct 'Default' is internal and cannot be referenced from a default argument value
滑到最底部自定刷新,不然一定要拽一个才能开始加载
:(
我在 UICollectionViewController 中分别注册了 Cell 和 UICollectionElementKindSectionHeader:
self.collectionView!.register(WNHomeCollectionViewCell.self, forCellWithReuseIdentifier: cellReuseIdentifier)
self.collectionView?.register(WNHomeCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: sectionHeaderReuseIdentifier)
当我尝试成功加载到数据刷新 collectionView 的时候(直接 reloadData),这个 SectionHeader 会有一个很诡异的动画,如下图:
collectionView?.spr_setIndicatorHeader(action: { [weak self] in
self?.goodViewModel.getGoodList(goodParameter: WNGoodParameter(), onSuccess: {
self?.collectionView?.reloadData()
}, onFailure: { (_) in
}, completion: {
self?.collectionView?.spr_endRefreshing()
})
})
Hi,
While using swiftpulltorefresh on ipad i figure out that when the content size is less the the height of scrollview the load more is not calling
7639337
这个修复iOS上KVO的问题,目前最新的release 3.1未包含该commit,麻烦给master分支发布下
change text, thx
footer 会显示在最上,而且无法 pull
In the case of the contentInsetTop
and contentInsetBottom
variables of RefreshView
, the value of contentInset
and the value of adjustedContentInset
are added.
However, this results in the same result as multiplying contentInset
twice.
Because the value of adjustedContentInset
is contentInset
plus the value of safeArea
.
The following fixes the problem where the scroll view is strange after refreshing or the value of contentOffset
that is necessary for refreshing is too large:
private extension UIScrollView {
var contentInsetTop: CGFloat {
if #available(iOS 11.0, *) {
return adjustedContentInset.top
} else {
return contentInset.top
}
return contentInset.top
}
var contentInsetBottom: CGFloat {
if #available(iOS 11.0, *) {
return adjustedContentInset.bottom
} else {
return contentInset.bottom
}
}
}
添加上拉加载没效果tableView.spr_setIndicatorAutoFooter {},未出现加载提示
Hello!
Latest commit broke indicator views when switching between tabs, see here:
Sample project can be downloaded here.
Reverting to v2.4.4 works fine.
I think the issue is that in v2.4.5 you moved the code to update tokens in RefreshView.swift
from func willMove(toWindow newWindow: UIWindow?)
to func willMove(toSuperview newSuperview: UIView?)
, but the latter isn't called when switching between tabs, so indicators are not updated properly.
A possible solution is to call the same code in both functions, but there should be a better one.
Thanks for your help!
在这个类中实现协议代理方法,只是为了便于子类重写再调用吗,并且还用到了KVO又是为什么?
let indicator = UIActivityIndicatorView(style: .medium)
Thanks for the pod; works like a charm!
Have a slight issue though. The pull down to refresh is working great if the scrollView is actually scrollable; meaning that its content height is bigger than the device height. However; if the scrollView is not scrollable because its content's height is not bigger than the device height; I cannot pull down to refresh. To better illustrate; I am adding 2 videos to show my issue.
What can I do to enable pull to refresh in the second case?
First Vid:
Scrollview is scrollable because its content height is bigger than device height. Pull to refresh working:
https://www.dropbox.com/s/8svkh5ntag5znfo/vid1.mov?dl=0
Second Vid:
Scrollview is not scrollable because its content height is smaller than device height. Pull to refresh is not working:
https://www.dropbox.com/s/v80yk4s1c0fsg2a/vid2.mov?dl=0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.