meismyles / swiftwebvc Goto Github PK
View Code? Open in Web Editor NEWA drop-in inline browser for your Swift iOS app.
License: MIT License
A drop-in inline browser for your Swift iOS app.
License: MIT License
When trying to display a local file like this url: "file:///var/mobile/Containers/Data/Application/blahblahblah/downloads/15212173031370-A8AB82E7-A719-4148-89CE-D5CE9FD468C6.jpg" it doesn't display anything. This is related to an old WKWebView bug that has since been fixed back in iOS 9.
It requires that we load the url with
webView.loadFileURL(url, allowingReadAccessTo: url)
instead of
webView.load(request)
I've managed to find a spot to drop that in that works, but is a little ugly and probably doesn't match the organization of the existing code very well.
If you drop the following code in right here it fixes things.
func loadRequest(_ request: URLRequest) {
if let url = request.url,
url.absoluteString.contains("file:"),
#available(iOS 9.0, *) {
webView.loadFileURL(url, allowingReadAccessTo: url)
} else {
webView.load(request)
}
}
When trying to compile the framework this error arrises:
SwiftWebVC/SwiftWebVC/SwiftWebVC.swift:133:75: Cannot assign value of type 'UIColor?' to type 'UIColor!'
Hello,
I recently received an email from Apple saying:
The App Store will no longer accept new apps using UIWebView as of April 2020, and existing apps must remove the deprecated API by December 2020. Migrate to the more secure and reliable WKWebView as soon as possible.
Does SwiftWebVC still use UIWebView? I can see one reference to it in the code - https://github.com/meismyles/SwiftWebVC/blob/0.4.2/SwiftWebVC/SwiftModalWebVC.swift#L20
Can you please merge some of the open PRs which fix Swift syntax and update cocoapods?
For example, if you are playing audio in a modal web VC and dismiss it the audio continues playing.
I believe this is due to the doneButtonTapped
method being handled by the child webViewController: SwiftWebVC
The share button crashes each time. Dont know what is wrong. Please check it out
Hi, I've tried adding SwiftWebVC to an empty project via CocoaPods but there is an issue with image assets in the bundle. It looks like once the pod is installed, image assets are not a part of the bundle anymore (although if you look on the filesystem, they are). The result is that the images aren't loaded when the browser view is displayed. Attached screenshot shows the issue.
If you need more information, please let me know.
Is it possible to support Swift 5?
Hello and thank you for this library! I have a project with both Swift and legacy Objective C ViewControllers and I am trying to use this library from my objc classes but I cannot call the initializers.
From swift it works fine and its great. :) Any plans on adding obj c support? (Since this library uses the WKWebView while the objc library this is based on uses the deprecated UIWebView)
Hi thanks for the great code! I am trying to find a way to inject JavaScript to the embedded WebView. Could anyone shed some lights here? Thanks!
Opening the following link in SwiftWebVC and trying to open a hyperlink of that page does not work.
http://site.petitrc.com/reglages/yokomo/SetupSheetsYokomoBD8.html
On iOS11 showing the browser crashes in SwiftWebVC.swift
in method updateToolbarItems()
on
let refreshStopBarButtonItem: UIBarButtonItem = webView.isLoading ? stopBarButtonItem : refreshBarButtonItem
with Thread 1: EXC_BAD_ACCESS (code=2, address=0x604000286f90)
when the browser is first opened.
I've been on/off with SwiftWebVC because it used up A LOT of storage. Haven't specifically found anything yet, so decided to post this issue up.
Link to Icon8 in the readme doc after updating to new images.
Is there any way to insert myself into the html loading process? I'd like to apply a few simple text replacements with the html, but the delegate only gives me start and finish call backs.
Is the only way to wait until it has been loaded and then pull the HTML from the webview, change it, and then set it? If so, will that trigger the didFinishLoading() callback again?
Also, you don't need to create Ipad specific images. You can check iPhone and iPad from attributes inspector
there is a log info
crash log:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Completion handler passed to -[SwiftWebVC.SwiftWebVC webView:decidePolicyForNavigationAction:decisionHandler:] was called more than once'
*** First throw call stack:
(0x18606c4e8 0x1a89dc528 0x18606c430 0x18e3538c0 0x18e3996f4 0x1095fc0f0 0x1095fbf1c 0x1095fc0b0 0x18e397258 0x18e4f9fcc 0x18e522c78 0x18e51c32c 0x18e394bdc 0x18e56ee50 0x18e356440 0x18e353db8 0x18e356670 0x18942c178 0x18942c438 0x1860131a0 0x1860129d4 0x18601057c 0x185f2b03c 0x19679ef94 0x18cef086c 0x1042d4030 0x1a974bd1c)
libc++abi.dylib: terminating with uncaught exception of type NSException
How to set default navigation title if no title returned in document.title?
Error:
Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service
I have tried running in Simulator iOS 8.1 and everything is working well except #22
I think you could change deployment target to 8 in the podspec
I have installed this pod for swift 4.2.
It causes some errors while compiling. So I unlocked the Podfiles and fixed it for swift4.2.
But, the problem is, the 'Done' Button isn't appear.
I found this pod for that point. To back my app.
Can you explain more about it or provide any updated versions of this Pod?
It would be nice if SwiftWebVC can decide whether to allow or cancel its navigation like WKNavigationDelegate's webView(_:decidePolicyFor:decisionHandler:)
If this is acceptable idea, I'm happy to make a PR for this ๐
When pushing SwiftWebVC on the navigation controller and pressing back again before loading, it can cause SwiftWebVC to crash due to forced unwrapped optionals.
Solution:
from line 197
in SwiftWebVC.swift
replace
if !closing {
if presentingViewController == nil {
navigationController!.toolbar.barTintColor = navigationController!.navigationBar.barTintColor
}
else {
navigationController!.toolbar.barStyle = navigationController!.navigationBar.barStyle
}
navigationController!.toolbar.tintColor = navigationController!.navigationBar.tintColor
toolbarItems = items as? [UIBarButtonItem]
}
with
if let navigationController = navigationController, !closing {
if presentingViewController == nil {
navigationController.toolbar.barTintColor = navigationController.navigationBar.barTintColor
}
else {
navigationController.toolbar.barStyle = navigationController.navigationBar.barStyle
}
navigationController.toolbar.tintColor = navigationController.navigationBar.tintColor
toolbarItems = items as? [UIBarButtonItem]
}
in SwiftWebVC.swift
, i have added config as follw
public class SwiftWebVC: UIViewController,WKScriptMessageHandler {
public var jsHandler:((WKScriptMessage)->())?
...
}
lazy var webView: WKWebView = {
let configuration = WKWebViewConfiguration()
configuration.userContentController.add(self, name: "wawa")
var tempWebView = WKWebView(frame: UIScreen.main.bounds, configuration: configuration)
tempWebView.uiDelegate = self
tempWebView.navigationDelegate = self
return tempWebView;
}()
public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
if self.jsHandler != nil {
self.jsHandler!(message)
}
}
and it just fail to work, maybe i need help.
Trying SwiftWebVC out for the first time and I'm having a problem loading certain pages. This is how I show it:
let webVC = SwiftWebVC(urlString: "http://www.udwa.org/our-union/")
webVC.delegate = self
self.navigationController?.pushViewController(webVC, animated: true)
The delegate call back tells me that it started loading, after 30 seconds I get the following in the console:
2017-10-14 11:57:05.941522-0700 udw[61741:29492827] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
2017-10-14 11:57:05.942308-0700 udw[61741:29492827] Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service
I tried several other URLs:
I get the same behavior when using the SwiftModalWebVC
.
Any help is appreciated.
When using your module inside UIPagerViewController app will crash. It happening because deinit method accessing lazy var that not initialized yet. So lazy var perform init and try to set deallocating object as delegate to WKWebView.
UIPagerViewController requires two VC (in case when pager view displays only one VC at time), one of them will be unused and deallocated before loadView() was called.
Like didStartLoading
, didFinishLoading
, didFailLoading
This way we can show a progress while loading
Seems like the title of subpages is not always centered. If I open the viewController as follows and navigate back and forth in the pages, sometimes the title is aligned left, instead of center (see screenshot below: Kontakte
title in bar on top).
UINavigationController(rootViewController: SwiftWebVC(urlString: "https://mandelkind.help/valletti"))
http://code.tutsplus.com/tutorials/ios-9-getting-started-with-sfsafariviewcontroller--cms-24260
Apple did open their Safari to developers and I think it would be great to integrate it in this library. Just a few line of codes that check iOS version and we're done.
I'm gonna make a PR soon.
Hi, I wanted to know if I add this framework does it take up memory when it isn't in use?
public convenience init(urlString: String) {
var urlString = urlString
if !urlString.hasPrefix("https://") && !urlString.hasPrefix("http://") {
urlString = "https://"+urlString
}
self.init(pageURL: URL(string: urlString)!)
}
when urlString
is invalid, URL(string: urlString)
is nil - that leads to crash.
I am using below code,
let webVC = SwiftWebVC(urlString: "http://google.com")
self.navigationController?.pushViewController(webVC, animated: true)
But I don't see Done button on top.
This is the most important part of this lib and its missing.
** You have this functionality in Modal.
Hello, I have upgraded to swift 4.2, and for the legacy objective c code that needs SwiftWebVC it is now required to specify @objc on each method, class, var etc.
Hey @meismyles
I've noticed that the modal version of the browser uses a V
icon for dismissing the modal view instead of the more traditional and well-established X
.
Is this something that you could change or at least make configurable?
Version: 0.4.0
I noticed there are two cases where your module gets stuck on a blank screen with a spinning Activity Indicator (see screenshot):
let webVC = SwiftModalWebVC(urlString: "www.google.com")
let webVC = SwiftModalWebVC(urlString: "http://www.google.com")
I'm able to make this work if you create an iOS 8+ ATS exception for each HTTP domain or if you set NSAllowsArbitraryLoads
.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
My question is: is there any way to allow HTTP links on WKWebView without doing the above?
Thanks!
Hi, are you considering update it to support swift 4?
Thanks
bottom part of site doesn't see because of toolbar
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.