1

I have very simple iOS app - it have TableView and list of custom cells in this TableView. There is an ImageView (that use downloadedFrom method to load images) in each cell.

After updating my Xcode to 8 version and converting project to Swift 2.3 I got very interesting result when - I reload list of items inside TableView - first cells on screen don't have any images and when i start to scroll down i see that other images are loaded fine. When scroll back to top - all images are fine.

I also tried to change the way of image loading to library called SDWebImage but result is the same. What is wrong?

extension UIImageView {
func downloadedFrom(link link:String, contentMode mode: UIViewContentMode) {
    guard
        let url = NSURL(string: link)
        else {return}
    contentMode = mode
    NSURLSession.sharedSession().dataTaskWithURL(url, completionHandler: { (data, response, error) -> Void in
        guard
            let httpURLResponse = response as? NSHTTPURLResponse where httpURLResponse.statusCode == 200,
            let mimeType = response?.MIMEType where mimeType.hasPrefix("image"),
            let data = data where error == nil,
            let image = UIImage(data: data)
            else { return }
        dispatch_async(dispatch_get_main_queue()) { () -> Void in
            self.image = image
        }
    }).resume()
}}
Ramkrishna Sharma
  • 6,715
  • 2
  • 37
  • 50
moonvader
  • 16,681
  • 16
  • 62
  • 106

1 Answers1

1

The problem was not in the loading method but in rounded corners of images. The problem with rounded corners in Xcode 8 and iOS 10 can be found here.

Community
  • 1
  • 1
moonvader
  • 16,681
  • 16
  • 62
  • 106