我有一系列网址,我正在尝试使用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
感谢任何帮助!
答案 0 :(得分:2)
据我所知,kf_setImageWithURL
需要NSURL,而不是String。
首先将arrPagePhoto[index]
转换为NSURL,然后将其传递给kf_setImageWithURL
:
let downloadURL: NSURL = NSURL(string: arrPagePhoto[index])!
pageContentViewController.imageView.kf_setImageWithURL(downloadURL)