Eureka: Form inside a View instead ViewController

Created on 13 Oct 2016  路  13Comments  路  Source: xmartlabs/Eureka

I wonder if I can add my form within a UIView instead of a ViewController, I need some graphics on the top, just before of the Form

appearance question

Most helpful comment

@rjjohnpatrickcruz Here's what worked for me:

I believe you have to use a UITableView, not a UIView.

  1. Add your UITableView to the view in your storyboard. Make sure the table view is styled as grouped rather than plain
  2. Drag from the tableView circle in the Outlets panel in the Connections Inspector. This outlet is provided by Eureka's FormViewController so there is no need to override it or create a new @IBOutlet for the table view
    drag
  3. Continue with your code as normal. The form variable now references your UITableView:
    override func viewDidLoad() {
        super.viewDidLoad()

        form +++ Section() { section in
            section <<< TextRow() {// etc...
        }
    }

All 13 comments

Just make a UITableView where you want your form to be and then hook it up to the tableView IBOutlet in FormViewController.

Exactly, your tableView does not have to occupy the whole screen.

@pwicks86 @christianhr any code sample. how to hook it up?
I tried something and it builds but crashes. thanks

import UIKit
import Eureka

class ViewController: UIViewController {

    @IBOutlet weak var tableFormView: FormViewController!

    override func viewDidLoad() {
        super.viewDidLoad()


        tableFormView.form = Section()
            <<< TextRow(){ row in
                row.title = "Text Row"
                row.placeholder = "Enter text here"
            }
            +++ Section()
    }
}

I get an error on this when i try with Swift 3

screen shot 2017-01-27 at 12 53 25 pm

@mats-claassen How exactly is this done? I've tried following the above recommendation but I've hit a wall. In IB there is no outlet called tableView in the Connections inspector.

screenshot 2017-01-31 17 25 52

The second attempt I made was to override the tableView property but again I hit a wall. Two compilation errors:

Overriding non-open var outside of its defining module and Cannot override with a stored property 'tableView'.

screenshot 2017-01-31 17 25 09

The third attempt I made was to programmatically set constraints on tableView which does work but is a bit of an inconvenience.

override func viewDidLoad() {
        super.viewDidLoad()

      tableView?.translatesAutoresizingMaskIntoConstraints = false
        view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[tableView][footerButton]|", options: [], metrics: nil, views: ["tableView" : self.tableView!, "footerButton" : footerButton]))
        view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[tableView]|", options: [], metrics: nil, views: ["tableView" : self.tableView!]))
        view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[footerButton]|", options: [], metrics: nil, views: ["footerButton" : footerButton]))

...

@pouriaalmassi Did you install Eureka by Carthage? I had that issue as well. It seems to be an bug between Carthage and XCode and I applied the hackaround described in this issue:

295

@developerdalelaw I am using Carthage to install Eureka. Will file a bug if there isn't one already. Thanks for the tip!

Hi Reopening this one, I'm using cocoa pods and trying to use a uiview instead of the uiviewcontroller, any suggestion on how I can achieve this? I'm using latest pod version, swift 3 Hoping for your kind response. Thanks.

@rjjohnpatrickcruz Here's what worked for me:

I believe you have to use a UITableView, not a UIView.

  1. Add your UITableView to the view in your storyboard. Make sure the table view is styled as grouped rather than plain
  2. Drag from the tableView circle in the Outlets panel in the Connections Inspector. This outlet is provided by Eureka's FormViewController so there is no need to override it or create a new @IBOutlet for the table view
    drag
  3. Continue with your code as normal. The form variable now references your UITableView:
    override func viewDidLoad() {
        super.viewDidLoad()

        form +++ Section() { section in
            section <<< TextRow() {// etc...
        }
    }

Thanks, @nikarc !

Old thread but I think this could be a part of documentation... :) Or maybe I should've known it as common iOS knowledge but I hadn't encountered this situation before where the outlet is defined in the inherited parent class.

@stami I agree, this should be part of the documentation.

this is the process to add borders:

Screen Shot 2019-04-17 at 11 39 13
Screen Shot 2019-04-17 at 11 39 39
Screen Shot 2019-04-17 at 11 39 59
Screen Shot 2019-04-17 at 11 40 27
Screen Shot 2019-04-17 at 11 40 46

I hope this helps someone - I appreciate this isn't exactly what the question was about but I had to put this somewhere it has taken me two days to figure this out.. there is very little online other than people asking asn other people not telling them exactly what to do

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sedwo picture sedwo  路  3Comments

tc picture tc  路  3Comments

jaylyerly picture jaylyerly  路  3Comments

allanrojas picture allanrojas  路  3Comments

calli23 picture calli23  路  3Comments