Search code examples
iosswiftresearchkit

Navigation title not showing up in ResearchKit


How do you display the title of a TaskViewController in Research Kit? I've been trying the following and it doesn't seem to be showing up, although other properties can be set in this way.

    let taskViewController = ORKTaskViewController(task: ConsentTask, taskRunUUID: nil)
    taskViewController.navigationBar.topItem!.title = "TITLE"
    taskViewController.restorationIdentifier = "1"
    taskViewController.delegate = self
    presentViewController(taskViewController, animated: true, completion: nil)

I have also tried taskViewController.title = "TITLE".


Solution

  • You need to perform two steps:

    1) Turn off the progress title:

    taskViewController.showsProgressInNavigationBar = NO;
    

    2) Implement and set a delegate for ORKTaskViewController:

    - (void)taskViewController:(ORKTaskViewController *)taskViewController stepViewControllerWillAppear:(ORKStepViewController *)stepViewController {
        stepViewController.title = @"Your title";
    }