Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved XLFormOptionsViewController customization support #562

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tarbayev
Copy link

I needed to display images in options cells. So I extended XLFormOptionObject with an optional method configureCell:. By implementing this method objects can perform extra customization on a cell provided.

I also added cellReuseIdentifier optional property, which allows the option to be displayed by a custom cell.

And one small sort of fix: if tableView property has been set for XLFormViewController there should be no extra manipulation with the view hierarchy. This allows us to set tableView as a view controller's root view.

@WA-Will
Copy link

WA-Will commented Jan 29, 2016

Can I ask how exactly you did this? I've been trying to change the background color of cells for a few days now and can't quite get it.

@tarbayev
Copy link
Author

Did what? Normally you change the background color of a cell by setting view with the color you need to its backgroundView property. Unfortunately XLForm is not very extensible and it's impossible to access a cell directly to make additional setup. You can only set some attributes in configuration dictionaries of XLFormRowDescriptor which are set to cell with setValue:forKey: method.
What I did, I've implemented an NSObject category with a block property. In a setter block is called with self as its argument (https://gist.github.com/tarbayev/c1cccbb6d2fdfa1227cb). So it's basically a visitor pattern implemented with block. Setting this property name as a key to configuration dictionary of XLFormRowDescriptor I'm able to access its cell and do any additional setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants