frederik-jacques / TNImageSliderViewController

A Swift image slider component based on UICollectionView
https://the-nerd.be/2015/06/22/tnimagesliderviewcontroller-image-slider-for-swift/
MIT License
90 stars 30 forks source link

fatal error: unexpectedly found nil while unwrapping an Optional value #11

Open tecexpert opened 8 years ago

tecexpert commented 8 years ago

Error in this line:

// 1. Set the image array with UIImage objects
imageSliderVC.images = [image1, image2, image3]

There is my po Log

(lldb) po image1
<UIImage: 0x7fe643d1f2c0>, {320, 152}

(lldb) po image2
<UIImage: 0x7fe643d21590>, {320, 152}

(lldb) po image3
<UIImage: 0x7fe643d21e10>, {320, 152}
Eder87rh commented 8 years ago

I have the same problem

2113industries commented 8 years ago

Any solution to this? I'm having the same issue!

frederik-jacques commented 8 years ago

Are you sure the view controller has already been loaded? When the image property is set, the collectionview's reloadData method is called. It could be that the collectionview hasn't been created yet.

Only set the images property, after the viewDidLoad has been called (at that point all UI elements have been created).