0

In my project I have different UI representations of the same model object : my entity can be represented as a table section header (UITableViewHeaderFooterView), table cell (UITableViewCell), collection section header (UICollectionReusableView) or a collection cell (UICollectionViewCell).

This representations have separate views (.xib) but they present the same object with the same behavior (UI bindings, actions, ...). For now i have a class by view (UITableViewHeaderFooterView + UITableViewCell + UICollectionReusableView + UICollectionViewCell) but i have a lot of common code to all classes.

I wonder how to gather this common behaviors in a one class in order to manage all my representations with the same class. I created a class (herited from UIView) with the common behavior but i can't use it in my Table/Collection classes since multiple inheritance is not possible.

1
  • Can you shows us with pictures what you are trying to achieve? Commented Dec 6, 2018 at 11:00

1 Answer 1

1

Try to create one UIView and do all setup code in it. For each type (UITableViewCell, HeaderFooterView) create a subclass and add your view as subview to it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.