【发布时间】:2016-08-06 03:11:45
【问题描述】:
我正在使用我在 localhost 上开发的网站,并且我想将来自该网站的文件的 localhost url 显示到我的 Xcode 项目中。如果我选择将文件显示为 .html 文件,问题并不是真正显示材料,但我真的很难找到一种同时显示网站和捕获 php 数据的方法。我试过这段代码
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let URL = NSURL(string: "http://localhost/home.php")
webView.loadRequest(NSURLRequest(URL: URL!))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
没有任何效果,但它确实适用于 google.com 和其他网站。
【问题讨论】:
-
您必须对 php 文件执行 HTTP 请求才能真正从中获取任何数据。 php文件由什么组成,如果你能更好地解释情况,你可能会更好地这样做。
标签: php html swift uiwebview localhost