Eureka: MultipleSelectorRow customization

Created on 5 Dec 2016  路  5Comments  路  Source: xmartlabs/Eureka

I'm trying to customize background of controller presented by MultipleSelectorRow, but I cannot, because tableView is nil when I add something in onPresentCallback

  <<< MultipleSelectorRow<String>("select") { row in
    row.options = values
    row.onPresentCallback = { _, to in
     let backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: (self.tableView?.bounds.size.width)!, height: (self.tableView?.bounds.size.height)!))
     backgroundView.backgroundColor = UIColor.red
     to.tableView?.backgroundView = backgroundView
    }
  }

Here are some screenshot to understand better:

https://i.stack.imgur.com/vCiU2.png
https://i.stack.imgur.com/ZW6pK.png

onPresent MultipleSelectorRow SelectorRow awaiting response

Most helpful comment

have you tried getting the view instead the tableView to force viewDidLoad before changing the tableView background color?

<<< MultipleSelectorRow<String>("select") { row in
    row.options = values
    row.onPresentCallback = { _, to in
     let _ = to.view
     let backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: (self.tableView?.bounds.size.width)!, height: (self.tableView?.bounds.size.height)!))
     backgroundView.backgroundColor =.red
     to.tableView?.backgroundView = backgroundView
    }
  }

All 5 comments

This solution seems to works, not sure if it is the best solution:

import Foundation
import Eureka
import ChameleonFramework

public class MFAMultipleSelectorViewController<T:Hashable> : MultipleSelectorViewController<T> {

  open override func viewDidLoad() {
    super.viewDidLoad()
    setTableViewBackgroundGradient(FlatMintDark(), FlatMintDark().lighten(byPercentage: 0.05)!)
  }
}

open class _MFAMultipleSelectorRow<T: Hashable, Cell: CellType>: GenericMultipleSelectorRow<T, Cell, MFAMultipleSelectorViewController<T>> where Cell: BaseCell, Cell: TypedCellType, Cell.Value == Set<T> {
  public required init(tag: String?) {
    super.init(tag: tag)
  }
}

public final class MFAMultipleSelectorRow<T: Hashable> : _MFAMultipleSelectorRow<T, PushSelectorCell<Set<T>>>, RowType {
  public required init(tag: String?) {
    super.init(tag: tag)
  }
}

have you tried getting the view instead the tableView to force viewDidLoad before changing the tableView background color?

<<< MultipleSelectorRow<String>("select") { row in
    row.options = values
    row.onPresentCallback = { _, to in
     let _ = to.view
     let backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: (self.tableView?.bounds.size.width)!, height: (self.tableView?.bounds.size.height)!))
     backgroundView.backgroundColor =.red
     to.tableView?.backgroundView = backgroundView
    }
  }

great! that works 馃憤
another small question, how can I customize the UIPickerView inside the PickerInlineRow without subclassing everything? I would like to change the font color to white

Please open another issue.

Is there a way to change the labelFont of the cell labels in the pushed view controller? I can't seem to find out a way to do it.

Was this page helpful?
0 / 5 - 0 ratings