- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
我正在尝试下载图片。
这是图片链接
https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png
我所做的是:
let url = NSURL(string: "https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png")
let session = NSURLSession.sharedSession()
let task = session.downloadTaskWithURL(url!, completionHandler: {(url, response, error) in
if let error = error {
print("error = \(error)")
}
if let response = response {
print("response = \(response)")
}
})
task.resume()
真的我有一个回应,我可以在日志中看到它如下:
response = <NSHTTPURLResponse: 0x7fc1a1427060> { URL: https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png } { status code: 200, headers {
"Cache-Control" = "private, max-age=31536000";
"Content-Length" = 13504;
"Content-Type" = "image/png";
Date = "Mon, 23 Nov 2015 23:57:55 GMT";
Expires = "Mon, 23 Nov 2015 23:57:55 GMT";
"Last-Modified" = "Fri, 04 Sep 2015 22:33:08 GMT";
Server = sffe;
"alt-svc" = "quic=\"www.google.com:443\"; p=\"1\"; ma=600,quic=\":443\"; p=\"1\"; ma=600";
"alternate-protocol" = "443:quic,p=1";
"x-content-type-options" = nosniff;
"x-xss-protection" = "1; mode=block";
} }
我的问题是在获取实际图像的响应中没有数据。我曾经调用 dataTaskWithRequest
并且它的 clouser 有这样的数据:
session.dataTaskWithRequest(request, completionHandler: {(data, response, error)
但是我在这里没有找到数据,请问我哪里错了?
这个问题在这里已经有了答案: Loading/Downloading image from URL on Swift (39 个答案) 关闭 7 年前。 我正在尝试下载图片。 这是图片链接 http
当我使用从另一个 Web 服务检索的 url 获取图像数据,并且我需要更新模型对象时,我总是在更新相应的 View 时遇到问题。本质上,这是问题所在: 调用 Web 服务 A 检索图像 URL - 第
这是我的下载代码: let url = NSURL(string:"http://www.zastavki.com/pictures/originals/2013/Photoshop_Image_of
我正在观看斯坦福 CS193p 讲座视频。从 Flickr 下载一些照片时,讲师同时使用了 downloadTaskWithRequest: 和 downloadTaskWithURL:。我有点困惑。
我正在使用 downloadTaskWithURL 下载视频,并使用以下代码将其保存到我的图库中: func saveVideoBis(fileStringURL:String){ p
因此,我在使用 Swift 的过程中遇到了另一个障碍。我正在尝试将多个图像加载到图像库中 - 除了一件事之外,一切都很好。尽管我清除了图像,但应用程序的内存使用量不断增长。基本排除所有代码后,发现这是
downloadTaskWithURL 函数有时会为不存在的文件返回一个非零位置。 在测试环境中http://192.168.0.102:3000/p/1461224691.mp4没有文件 大多数时候
我是一名优秀的程序员,十分优秀!