2

I've made a ResearchKit survey with 11 steps, but I'd like to remove the default cancel button that's on the bottom of every question.

I've come across this command:

stepViewController.cancelButtonItem = nil;

But I can't seem to find the right place for it.

Thanks.

1 Answers1

1

The correct place would be in the delegate callback. The documentation states "The cancel button item is updated during view loading and when the value of the step property is changed, but is safe to set in the taskViewController:stepViewControllerWillAppear: delegate callback."

And as an example:

func taskViewController(_ taskViewController: ORKTaskViewController, stepViewControllerWillAppear stepViewController: ORKStepViewController) {

    stepViewController.cancelButtonItem = nil

}

That being said, the functionality currently seems to be broken in the most recent version of ResearchKit per these issues on their repo.

https://github.com/ResearchKit/ResearchKit/issues/1273

It currently will disable the functionality of the cancel button, but does not correctly remove the button from the ORKNavigationContainer. If you find a solution, please let me know, had the issue posted on their repo as well as a few other places for some time now with no luck.

Chris Peragine
  • 158
  • 2
  • 8
  • 2
    Got it working with a somewhat disgusting fix. First, defined an objc function 'nothing' that does nothing, then did the following: stepViewController.cancelButtonItem = UIBarButtonItem(title: "", style: .plain, target: self, action: #selector(self.nothing)) It's invisible, and does call the function, but nothings happens (or whatever you want). Best I've been able to figure out :\ – Solomon Bhandari Jun 28 '19 at 03:03
  • 1
    Yeah, that's the same hack I use to hide it currently until the gods of RK respond, there really doesn't seem to be another simple solution. It does make everything wonky though with the spacing on the skip button. Half debated going rogue and diving into the lib but afraid I'd introduce some weird regression. – Chris Peragine Jun 28 '19 at 13:24
  • 1
    Gotcha. If you figure anything out let me know! – Solomon Bhandari Jun 30 '19 at 19:57