Skip to content

Improved XLFormOptionsViewController customization support#562

Open
tarbayev wants to merge 4 commits into
xmartlabs:masterfrom
tarbayev:master
Open

Improved XLFormOptionsViewController customization support#562
tarbayev wants to merge 4 commits into
xmartlabs:masterfrom
tarbayev:master

Conversation

@tarbayev
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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