iOS 8.1 杀死了我的 WebView 的一部分。把招工广告

标签 ios xcode swift webview

我更新到了 iOS 8.1 并更新了我的 xcode,但现在我的 webview 出现了问题。

我使用了这部分代码:

let stream = "http://stream.hive365.co.uk:8088/live"
    let url  = NSURL(string: stream)
    let request = NSURLRequest(URL: url)
    webplayer.loadRequest(request)

xcode 给出有关 let 请求的错误

value of optional type NSURL? not unwrapped; did you mean to use! or ?

我是 iOS 快速开发新手,无法消除错误......

如有任何帮助,我们将不胜感激!

最佳答案

NSURL 返回 optional所以你需要检查它是否为 nil

let stream = "http://stream.hive365.co.uk:8088/live"
if let url  = NSURL(string: stream) {
  let request = NSURLRequest(URL: url)
  webplayer.loadRequest(request)
}

关于iOS 8.1 杀死了我的 WebView 的一部分。把招工广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26473218/

相关文章:

ios - 更新 iOS 中 UI 元素的单元测试方法

SwiftUI 可观察对象未观察到

iOS:如何从一个应用程序打开其他已安装的应用程序?

ios - iOS 中的 SQLite select 语句断言失败

xcode - 升级后,Xcode 上的 Flutter 应用程序无法启动

ios - Xcode 找不到我的单元格标识符

ios - Google Drive API (GTL) - 按顺序创建多个文件夹路径?

iOS 7 严重故障 : the LastResort font is unavailable

ios - 如何使用 iOS 显示多个 OpenGL ES 2.0 View ?

ios - 新 View 中的 Swift 动画立即发生