Kate M
Kate M

Reputation: 488

Eureka PushRow on a modal, view won't close after item selection

I am using a SplitViewController and on the detail page (which is set to "defines context"), the user can select "+" in the navbar and I present the next view controller "modally over current context" using a segue. On that view controller I am using Eureka and one of the rows I want to use is PushRow. The issue I am running into is when I select an option on the PushRow, the view (table of options to choose that Eureka generated) never closes. The list of options stays full screen. I can see that PushRow.onChange is called and it has the correct value. For some reason that topmost view will not close.

I dug deeper and it seems like I need to modify the PushRow presentationMode to be "presentModally" since I am presenting it from a modal. However, I am not sure what to put for the controllerProvider. Is this the right path? If so, what would the correct syntax be? I also tried doing a reload in the onChange but that didn't make a difference.

private func getGroupPushRow() -> PushRow<String> {
    return PushRow<String>() {
        $0.title = "Group"
        $0.selectorTitle = "What is the Group?"
        $0.noValueDisplayText = "Select a Group..."
        $0.options = self.getGroups()
        $0.presentationMode = PresentationMode.presentModally(controllerProvider: ControllerProvider<VCType>, onDismiss: { () in

        })
        $0.onChange({ (row) in
            print("in onchange \(row.value)")
          //  row.reload()
          //  self.tableView.reloadData()
        })
    }
}

Upvotes: 1

Views: 956

Answers (1)

Kate M
Kate M

Reputation: 488

I eventually figured out a solution so I'm posting it here to hopefully help out somebody else. Going off of the example above, replace presentationMode & onChange with this code. Note that if you are using another object in your PushRow besides String, then the type in PushSelectorCell should be that type instead.

$0.presentationMode = PresentationMode.presentModally(
      controllerProvider: ControllerProvider.callback {
          return SelectorViewController<SelectorRow<PushSelectorCell<String>>> { _ in }
      },
      onDismiss: { vc in
          vc.dismiss(animated: true)
    })
$0.onChange({ (row) in
    row.reload()
})

Upvotes: 7

Related Questions