HamzaGhazouani/HGPlaceholders

[QUESTION] Custom placeholder without XIBs

adri4silva opened this issue · 1 comments

Is there any way to add a custom placeholder without using XIBs?
Is this implemented?
Are you interested in this kind of feature?

Thank you so much!

Okay, I figured out a solution for this.

  • Just create a standard CollectionViewCell/TableViewCell programatically

  • Add this to PlaceholdersProvider:

private static var programaticallyPlaceholder: Placeholder {
    let placeholder = Placeholder(cellIdentifier: "ProgramaticallyCollectionViewCell", key: PlaceholderKey.custom(key: "ProgramaticallyCell"))
    return placeholder
}

and

...
placeholdersProvider.add(placeholders: PlaceholdersProvider.programaticallyPlaceholder)ç
...
  • Then on your CollectionViewController, register the cell as standard
...
placeholderCollectionView?.register(ProgramaticallyCollectionViewCell.self, forCellWithReuseIdentifier: "ProgramaticallyCollectionViewCell")
...
  • And show that cell as custom placeholder
placeholderCollectionView?.showCustomPlaceholder(with: PlaceholderKey.custom(key: "ProgramaticallyCell"))

Hope that helps someone!