解决办法 放弃uniapp 打包 app 改为打包 h5
使用原生套壳展示
class ViewController: UIViewController {
lazy var webView = {
let scriptString = "document.documentElement.style.webkitUserSelect='none';"
let userScript = WKUserScript(source: scriptString, injectionTime: .atDocumentEnd, forMainFrameOnly: true)
let contentController = WKUserContentController()
contentController.addUserScript(userScript)
let configuration = WKWebViewConfiguration()
configuration.userContentController = contentController
let web = WKWebView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height),configuration: configuration)
return web
}();
override func viewDidLoad() {
super.viewDidLoad()
webView.uiDelegate = self;
webView.navigationDelegate = self;
self.view.addSubview(webView);
if let htmlFileURL = Bundle.main.url(forResource: "index", withExtension: "html", subdirectory: "h5") {
let absoluteURL = htmlFileURL.absoluteURL
webView.loadFileURL(absoluteURL, allowingReadAccessTo: absoluteURL.deletingLastPathComponent())
}
// Do any additional setup after loading the view.
}
}
修改打包配置 参考 https://blog.csdn.net/YourPasser/article/details/134039943
1 个回复
3***@qq.com (作者)
解决办法 放弃uniapp 打包 app 改为打包 h5
使用原生套壳展示
class ViewController: UIViewController {
}
修改打包配置 参考 https://blog.csdn.net/YourPasser/article/details/134039943