gpt4 book ai didi

ios - UIWebView 开始加载但从未完成

转载 作者:行者123 更新时间:2023-11-30 13:21:01 27 4
gpt4 key购买 nike

我的 UIWebView 开始加载网页,但从未完成,留下一个白色页面。我的代码如下

import UIKit

class WebsiteController: UIViewController, UIWebViewDelegate {
var index: Int = Int();
var postLink: String = String()

@IBOutlet weak var Browser: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let defaults = NSUserDefaults.standardUserDefaults()
let school = (defaults.objectForKey("School") as! String)
let bundleidentifier = NSBundle.mainBundle().bundleIdentifier
var links: [String] = [String]()
if let aStreamReader = StreamReader(path: NSBundle.mainBundle().pathForResource(school, ofType: "txt")!)
{
defer {
aStreamReader.close()
}
while let line = aStreamReader.nextLine() {
links.append(line)
}
}
let url: NSURL = NSURL(string: links[index].stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLPathAllowedCharacterSet())!)!
let request: NSURLRequest = NSURLRequest(URL: url)
Browser.loadRequest(request)
Browser.delegate = self
Browser.opaque = false
Browser.backgroundColor = UIColor .clearColor()
// Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func webViewDidStartLoad(webView: UIWebView) {
print("starting")
}
func webViewDidFinishLoad(webView: UIWebView) {
print("finishing")
}

所以在控制台中,当我加载此 View 时,我得到“开始”,但从未“完成”

最佳答案

检查 didFailLoadWithError 方法中是否存在错误。

关于ios - UIWebView 开始加载但从未完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37769001/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com