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

Form inside a View instead ViewController #723

Closed
christianhr opened this issue Oct 13, 2016 · 13 comments
Closed

Form inside a View instead ViewController #723

christianhr opened this issue Oct 13, 2016 · 13 comments

Comments

@christianhr
Copy link

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

@pwicks86
Copy link

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

@mats-claassen
Copy link
Member

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

@mcka
Copy link

mcka commented Nov 18, 2016

@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()
    }
}

@eliteproxy7
Copy link

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

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

@pouriaalmassi
Copy link

@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]))

...

@DaleLaw
Copy link

DaleLaw commented Jan 31, 2017

@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

@pouriaalmassi
Copy link

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

@rjjohnpatrickcruz
Copy link

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.

@nikarc
Copy link

nikarc commented Apr 26, 2017

@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...
        }
    }

@stami
Copy link

stami commented Sep 29, 2017

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.

@ltrojanowski
Copy link

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

olcayertas added a commit to olcayertas/Eureka that referenced this issue Aug 6, 2018
Showing forms in a subview of the view controller.
Original content was here: xmartlabs#723
@Coners
Copy link

Coners commented Apr 17, 2019

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

@Coners
Copy link

Coners commented Apr 17, 2019

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

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

No branches or pull requests