Comments (2)
I have a not perfect solution. In the idea, I was supposed to use the observer to track the wkwebview
.
But I did through a timer:
var needShowSpash: Bool = true
final class ViewController: VisitableViewController, ErrorPresenter {
public var startTimerLoader: Timer?
public var spashImage: UIImageView?
override func viewDidLoad() {
super.viewDidLoad()
self.startLoadingAnimate()
}
func startLoadingAnimate() {
if needShowSpash == false {
return
}
let image = UIImage(named: "Splash")
self.spashImage = UIImageView(image: image)
self.spashImage!.frame = UIScreen.main.bounds
self.view.addSubview(self.spashImage!)
self.startTimerLoader = Timer.scheduledTimer(timeInterval: 0.3, target: self, selector: #selector(ViewController.checkLoadingPageForHiddenSpash), userInfo: nil, repeats: true)
}
@objc func checkLoadingPageForHiddenSpash() {
if visitableView.webView?.estimatedProgress ?? 0.0 < 0.9 {
return
}
self.startTimerLoader?.invalidate()
self.startTimerLoader = nil
needShowSpash = false
UIView.transition(with: self.spashImage!,
duration: 0.5,
options: .transitionCrossDissolve,
animations: {self.spashImage!.alpha = 0},
completion: {_ in self.spashImage!.removeFromSuperview()}
)
}
}
If anyone has any suggestions on how to improve this would be great.
from turbo-ios.
Can you hook into the SessionDelegate
to learn when the first network request has completed? For example:
extension ViewController: SessionDelegate {
func sessionDidFinishRequest(_ session: Session) {
if view.subviews.contains(splashImage) {
splashImage.removeFromSuperview()
}
}
}
from turbo-ios.
Related Issues (20)
- Downloading the file from the link HOT 4
- Completion handler passed to -[Turbo.ColdBootVisit webView:didReceiveAuthenticationChallenge:completionHandler:] was not called HOT 2
- navigationController is nil in Demo HOT 1
- CSS not loading sometimes for Android and iOS app HOT 1
- Cancelled swipe back will reload page HOT 3
- Turbo-stream link with GET request being interpreted as HTTP request in turbo-ios HOT 6
- Quick Start Guide is partially outdated
- Focus on input field crashes the app HOT 2
- mobile rails app with Turbo.session.drive = false HOT 1
- Stimulus Binds Twice on New Page after Redirect to GET Request HOT 9
- Publishing to CocoaPods repo HOT 1
- Turbo for react native. HOT 2
- Turbo reload breaks webview HOT 1
- [Demo] TurboNavigationController.swift:93:41: Variable used within its own initial value
- Cast from 'Error' to unrelated type 'TurboError' always fails HOT 2
- Page restoration is broken on turbo-7.2.0-beta.2 HOT 3
- Effects for navigation bar in modal HOT 12
- Double request after redirect HOT 2
- Cookies get removed when app closes HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from turbo-ios.