STPostWebView 0.0.5

STPostWebView 0.0.5

Maintained by Suta.



  • By
  • Suta

STPostWebView

Language Platform Version License

A subclass of WKWebView that supports requested by POST

STPostWebView is a subclass of WKWebView that supports requested by POST.

STPostWebViewPreview01

Requirements

  • iOS 8.0 or later
  • ARC
  • Swift 5.0

Installation

STPostWebView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'STPostWebView'

Usage

Import headers in your source files

In the source files where you need to use the library, import the header file:

import STPostWebView

Initialize STPostWebView

STPostWebView is a subclass of WKWebView. You can initialize it like WKWebView:

STPostWebView(frame: frame, configuration: configuration)

Load POST request

var urlString = "http://xxxx:xxxx/xxxx"
let getParameterString = "key1=value1&key2=value2"
urlString += "?" + getParameterString
var request = URLRequest(url: URL(string: urlString)!)
request.httpMethod = "POST"
let postParameterString = "key3=value3&key4=value4"
request.httpBody = postParameterString.data(using: .utf8)
webView.load(request)

Run Example

In the Example directory there is a pages folder with some web files. Because PHP is used to write these web files, you need to configure the PHP environment on your computer. Then use the pages folder to start a server.

Finally, set the host of this server in the Example project, for example:

// ViewController.swift

let host = "http://localhost:80"

Author

Suta, [email protected]

License

MIT license.