Image not being loaded in AsyncImageView
我刚刚更新到 Xcode 7 和 Swift 2.0,当然它在我的应用程序中造成了一些问题。我已经解决了很多问题,但我正在努力解决这个问题。
在我的表格视图中,我正在从 Parse.com 加载图像,但由于某种原因,图像没有显示在 AsyncImageView 中。此代码在更新之前运行良好,所以我不确定问题是什么:
1
2 3 |
AsyncImageLoader.sharedLoader().cancelLoadingURL(cell.rideImageView.imageURL)
cell.rideImageView.image = UIImage(named:”Unloaded”) cell.rideImageView.imageURL = NSURL(string: ride.rideImageSmall!) |
我已检查以确保从 Parse 正确加载了图像 URL,并且确实如此。这是我正在使用的库:https://github.com/nicklockwood/AsyncImageView
有人有什么想法吗?
- 网址是什么样的?它是外部 URL,是 http:// 还是 https:// ?
- 这是一个例子 – http://files.parsetfss.com/0f7ec53c-ea56-4a8a-9927-9ff94e1c4??0bd/tfss-4471a63f-f2??37-4542-8cfb-e343b6f??a0242-Space%20Mounta??in_550x412.png
由于 Apple 的新”Apple Transport Security”自 iOS9 (= Xcode7) 以来一直处于活动状态,您可能会遇到网络请求被阻止的情况。如果您想从 http:// URL 加载数据,您需要告诉应用,ATS 不适用于您的应用或某些域。
Apple 的技术说明在这里:https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/
作为开始,您可以将带有条目 NSAllowArbitraryLoads = ON 的字典 NSAppTransportSecurity 添加到您的 Info.plist 中,看看您能走多远:
如果 ATS 设置的某些名称不适合您,请阅读以下博客文章,其中描述了不同的名称 – 这些过去对我有用:http://ste.vn/2015/06/10/配置-app-transport-security-ios-9-osx-10-11/
- 另一个快速的问题,我也在解析网页中的数据。我尝试使用相同的技术,但它不适用于此 URL – http://dlwait.zingled.com/mk。我正在使用 NSExceptionAllowsInsecureHTTPLoads 和 NSIncludesSubdomains,两者都设置为 YES。 NSExceptionDomains 是 http://dlwait.zingled.com。
- @user3746428 你只需要设置没有 http: 的域,所以只需使用 dlwait.zingled.com。尝试使用这个 NSTemporaryThirdPartyExceptionAllowsInsecureHTTPLoads(取自博客文章)而不是技术说明中的那个。
来源:https://www.codenong.com/32492073/