Ios Web视图未加载url请求和url显示为零
我想加载带有linkedin授权url的web视图,但在加载之前,并没有创建url,并声明它为零,并且web视图不显示任何特定页面。 这是传递给URLRequest的url字符串。 *******&重定向\u uri=**&state=linkedin1575812567&scope=r\u liteprofile 下面提到的是代码Ios Web视图未加载url请求和url显示为零,ios,swift,linkedin,Ios,Swift,Linkedin,我想加载带有linkedin授权url的web视图,但在加载之前,并没有创建url,并声明它为零,并且web视图不显示任何特定页面。 这是传递给URLRequest的url字符串。 *******&重定向\u uri=**&state=linkedin1575812567&scope=r\u liteprofile 下面提到的是代码 let responseType = "code" let state = "linkedin\(Int(NSDate().timeInterval
let responseType = "code"
let state = "linkedin\(Int(NSDate().timeIntervalSince1970))"
var authorizationURL = "\(authorizationEndPoint)?"
authorizationURL += "response_type=\(responseType)&"
authorizationURL += "client_id=\(linkedInConfig.linkedInKey)&"
authorizationURL += "redirect_uri=\(linkedInConfig.redirectURL)&"
authorizationURL += "state=\(state)&"
authorizationURL += "scope=\(scope)"
print(authorizationURL)
let url = URL(string: authorizationURL)
let request = URLRequest(url: url!)
webView.load(request)
URL只能包含一组特定的字符。使用其他字符可能会导致此类错误。或者,即使是允许的字符有时也会导致这种情况,例如,“&”用作分隔符,不能直接在URL查询参数值中使用 您可以使用此选项对这些混乱字符进行编码:
let newURL = YOUR_URL.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
let url = URL(string: newURL)
您是否正确地实现了web视图委托?很难从您的代码片段中理解问题所在。我正确设置了navigationdelegate。但它什么也没做。