Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storyboard UICollectionViewCell shows up, then goes blank

Problem:

I am working on a UIViewController on my Storyboard/Interface Builder, with a UICollectionView in it that defines a UICollectionViewCell. Everytime I change something in this cell, all its subviews goes to blank white, making it impossible to see anything. Also when I update constraints frame won't move even if I refresh, like the whole interface builder is broken. It's only for this UIViewController, sometimes does it for an other one. Interface Builder Builds show warnings from Pods (I can't help it). I have no broken constraints.

(Very) Temporary solution:

If I quit Xcode, clean, rebuild and re-open the Storyboard, it will be back to "almost" normal (meaning not all views shows properly but at least I can see them and it's not fully white) until I switch to an other file and come back. When I come back to the storyboard will be blank again. Sometimes I have to delete my DerivedData and the cell will display perfect. Only for a few minutes.

Also, I do not have any constraints warnings or anything.

EDIT: I removed all classes from all the views in the cell, just in case something in my custom views was causing these problems. My views mostly implement layers and gradients so I thought I might have been doing something wrong breaking the IB rendering. On the top of the cell there is a custom UIView that I made, that uses a CAGradientLayer. If I remove the class from this view, the cell will start displaying again. But I can't be sure this is the cause since when I leave the storyboard and come back on it, the cell will be white again. Without having putting back the class in place.

EDIT2: I uninstalled and reinstalled Xcode and cocoapods. Updated the pods. Created a new xcworspace.

Screenshot

enter image description here

enter image description here

Details on my environment

I am using Swift, XCode 9.3, Cocoapods 1.5.0, High Sierre 10.13.4 Feel free to ask any other details My Pods (that generate lots of warnings due to swift 4 compatibility) :

  pod 'FBSDKLoginKit'
  pod 'FBSDKCoreKit'
  pod 'FSPagerView'
  pod 'CropViewController'
  pod 'SwiftLint'
  pod 'Parse'
  pod 'Parse/FacebookUtils'
  pod 'ImagePicker'
  pod 'XLPagerTabStrip', '~> 8.0'
  pod 'Eureka'
like image 484
Scaraux Avatar asked May 04 '18 23:05

Scaraux


1 Answers

You should call the super parent in the awakeFromNib method.

You must call the super implementation of awakeFromNib to give parent classes the opportunity to perform any additional initialization they require.

override func awakeFromNib() {
  super.awakeFromNib()
  setup()
}
like image 51
Alexis Darnat Avatar answered Oct 13 '22 22:10

Alexis Darnat