swift4 WKWebView使用JS与Swift交互

2018-07-05 11:00:00   朋也   swift学习笔记(纯代码)   swift4 wkwebview javascript  

创建wkwebview

import WebKit

lazy var webView: WKWebView = {
    let preferences = WKPreferences()
    preferences.javaScriptEnabled = true

    let configuration = WKWebViewConfiguration()
    configuration.preferences = preferences
    configuration.userContentController = WKUserContentController()
    // 给webview与swift交互起一个名字:AppModel,webview给swift发消息的时候会用到
    configuration.userContentController.add(self, name: "AppModel")

    var webView = WKWebView(frame: self.view.frame, configuration: configuration)
    // 让webview翻动有回弹效果
    webView.scrollView.bounces = true
    // 只允许webview上下滚动
    webView.scrollView.alwaysBounceVertical = true
    webView.navigationDelegate = self
    return webView
}()

swift4 开发App,适配国际化,多语言支持

2018-06-20 14:37:00   朋也   swift学习笔记(纯代码)   swift4 localizable  

在项目里新建一个

Localizable.strings 文件

swift4 UITableView 下拉刷新上拉加载 MJRefresh 自定义用法

2018-06-20 11:09:00   朋也   swift学习笔记(纯代码)   swift4 MJRefresh pulluprefresh loadmore  

直接上图

自定义部分代码来自项目 https://github.com/Finb/V2ex-Swift 感谢 @Finb 大大开源的这么好的swift项目


       3 / 16