Search code examples
swifteureka-forms

Eureka: How to push a VC from a PushRow without Segue


I am using Eureka to do a settingsVC and I am having trouble pushing a newVC from a pushRow. Note that I do not use storyboard

My setup is relatively simple, and my newVC is a simple UIViewController with some uitextfields and labels. Because I do not use storyboard, I can't seem to use performSegues and $0.presentationMode = .segueName(segueName: "RowsExampleViewControllerSegue", onDismiss: nil)

I have also reviewed this post but this post is relatively far fetched for my application.

My implementation so far as such:

class AccountsViewController: FormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        form +++ Section("Profile")

            <<< PushRow<String>() { row in
                row.title = "Edit phone number"
                row.value = "+61 12345678"
                }.onCellSelection({ (cell, row) in
self.navigationController?.pushViewController(ChangePhoneNumberViewController(), animated: true)
            })

The above approach pushes the VC twice.

My reason for wanting to adopt pushRow is because I want it to adopt the pushRow aesthetic looks, like the image attached. I have also considered exploring ButtonRow but the UI/UX is just not right. Moving ahead I would also need to use protocols to bring the new "phoneNumber" to the AccountsViewController.

enter image description here

EDIT:

Attempted the following code but produces the error message. enter image description here


Solution

  • I was having the same error, you can try to include the return type and also the argument label builder to the callback:

    row.presentationMode = PresentationMode.show(
                    controllerProvider: ControllerProvider.callback(builder: { () -> UIViewController in
                        return AcknowListViewController()
                    }),
                    onDismiss: nil)