0

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

Koh
  • 2,687
  • 1
  • 22
  • 62

2 Answers2

0

I think you just need to set the presentation mode like this:

presentationMode = PresentationMode.show(
    controllerProvider: ControllerProvider.callback(
        {return ChangePhoneNumberViewController()}
    ), onDismiss: nil)

ControllerProvider.callback lets you provide a VC by returning one from a closure, instead of from a nib file or storyboard.

Sweeper
  • 213,210
  • 22
  • 193
  • 313
0

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)
kl.woon
  • 2,036
  • 1
  • 18
  • 10