Reuse id in nib does not match id used to register nib

I have a module / module written in Swift that provides some custom controls with IBDesignable functionality.

I am currently working on a CollectionView based control. CollectionView and custom CollectionViewCell are created in Nib files. To load the CollectionViewNib and add some design functionality, I use this NibDesignable class . After initializing the CollectionView, I register the CollectionViewCell like this:

let cellIdentifier = "collectionViewCell"

required public init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    self.setup()
}

override init(frame: CGRect) {
    super.init(frame: frame)
    self.setup()
}

private func setup() {
    let bundle = NSBundle(forClass: self.dynamicType)
    self.collectionView.registerNib(UINib(nibName: "CollectionViewCell", bundle: bundle), forCellWithReuseIdentifier: self.cellIdentifier)
}

      

After adding my Framework as inline binary to another application, I can use my new custom CollectionView as expected, but unfortunately the Designable function does not work well, the following error appears instead:

IB Designables: Failed to update auto layout status: 
The agent raised a "NSInternalInconsistencyException" exception: 
view reuse identifier in nib (ibCollectionViewCell) does not match the identifier used to register the nib (collectionViewCell)

      

As described above, My Control works in the Simulator and on my phone, so I don't use different IDs. I don't know where XCode gets this ibCollectionViewCell , but when I use it as an identifier for my CollectionViewCell, every thing works like a charm.

Any ideas where this ID comes from, and why XCode can't load my own CollectionViewCell with my own ID?

+3


source to share


1 answer


After upgrading from XCode 7 Beta 4 to Beta 5, the error went away. So my guess is that there was something inappropriate in the previous version.



0


source







All Articles