-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why NVActivityIndicatorPresenter is deprecated, whats the alternate approach? #315
Comments
Here's the simpler version that I'm using as a workaround as I move away from using app-global activity indicators. Hope it helps. (Note that I chose to put this API on import NVActivityIndicatorView
import UIKit
final class BlockingActivityIndicator: UIView {
private let activityIndicator: NVActivityIndicatorView
override init(frame: CGRect) {
self.activityIndicator = NVActivityIndicatorView(
frame: CGRect(
origin: .zero,
size: NVActivityIndicatorView.DEFAULT_BLOCKER_SIZE
)
)
activityIndicator.startAnimating()
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
super.init(frame: frame)
backgroundColor = UIColor.systemBackground.withAlphaComponent(0.6)
addSubview(activityIndicator)
NSLayoutConstraint.activate([
activityIndicator.centerXAnchor.constraint(equalTo: safeAreaLayoutGuide.centerXAnchor),
activityIndicator.centerYAnchor.constraint(equalTo: safeAreaLayoutGuide.centerYAnchor),
])
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension UIWindow {
func startBlockingActivityIndicator() {
guard !subviews.contains(where: { $0 is BlockingActivityIndicator }) else {
return
}
let activityIndicator = BlockingActivityIndicator()
activityIndicator.autoresizingMask = [.flexibleWidth, .flexibleHeight]
activityIndicator.frame = bounds
UIView.transition(
with: self,
duration: 0.3,
options: .transitionCrossDissolve,
animations: {
self.addSubview(activityIndicator)
}
)
}
} |
Thanks @sharplet, this is still better and let's see what author has thought about this? |
@preetamjadakar Technically, it's still usable, you will get some warnings though. There are changes in the pod names so use The above workaround should work. Originally, Long story short, alternatives could be:
Then what is Thanks for understanding. |
This is a really odd decision @ninjaprox |
This is honestly, quite stupid. Why would you do this? What's even the point? |
@ninjaprox am I wrong somewhere? |
I see, in the latest release
NVActivityIndicatorPresenter
is deprecated, not sure why but I'm looking for its alternative.My requirement is simple:
Something is deprecated meaning, planned for removal or not supported near future, so we can't just bear with the deprecation warnings.
My current implementation is as below:
var activityData = ActivityData()
To show:
NVActivityIndicatorPresenter.sharedInstance.startAnimating(activityData, nil)
To hide:
NVActivityIndicatorPresenter.sharedInstance.stopAnimating()
The text was updated successfully, but these errors were encountered: