繁体   English   中英

翠鸟-无法从Web加载图像URL

[英]Kingfisher - Cannot Load Image URL from Web

我有一个URL数组,我正在尝试使用KingFisher加载到ImageView中。

arrPageTitle = ["This is The App Guruz", "This is Table Tennis 3D", "This is Hide Secrets"];
    arrPagePhoto = ["https://s3.amazonaws.com/fan-polls/heyward_again.jpg", "https://s3.amazonaws.com/fan-polls/Schwarber.jpg", "https://s3.amazonaws.com/fan-polls/mike_ditka.jpg"];

我试图根据UIPageViewController的索引加载适当的图像:

pageContentViewController.imageView.kf_setImageWithURL((arrPagePhoto[index] as! String))

我收到致命错误:展开可选值时意外发现nil

任何帮助表示赞赏!

据我所知, kf_setImageWithURL需要NSURL,而不是String。

因此,首先将arrPagePhoto[index]转换为NSURL,然后将其传递给kf_setImageWithURL

let downloadURL: NSURL = NSURL(string: arrPagePhoto[index])!

pageContentViewController.imageView.kf_setImageWithURL(downloadURL)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM