Swift 3 WebView [英] Swift 3 WebView

查看:80
本文介绍了Swift 3 WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我刚刚更新到新的Xcode8Swift3,但是现在我的Web视图不起作用.这是我使用的代码:

So I just updated to the new Xcode8 and Swift3 but now my web view does not work. Here is the code I used:

UIWebView.loadRequest(webView)(NSURLRequest(URL: NSURL(string: "http://hardwirestudios.com")!))

现在给我这两个错误:

'NSURL'不能隐式转换为'URL';您是说要使用"as"进行显式转换吗?- "NSURLRequest"不能隐式转换为"URLRequest";您是要使用"as"进行显式转换吗?

'NSURL' is not implicitly convertible to 'URL'; did you mean to use 'as' to explicitly convert?- 'NSURLRequest' is not implicitly convertible to 'URLRequest'; did you mean to use 'as' to explicitly convert?

推荐答案

在这种情况下,请重新输入以下行:

For this exact situation, retype your line to:

yourWebView.loadRequest(URLRequest(url: URL(string: "http://hardwirestudios.com")!))

...,然后将yourWebView变量重命名为您实际使用的变量.

... and rename yourWebView variable to one, that you actually use.

在Swift 3.0中,使用 URL URLRequest ,因为几乎所有NS都已删除.

In Swift 3.0, use URL and URLRequest as almost all the NS were dropped.

这篇关于Swift 3 WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆