ORKStepViewControllerDelegate Protocol Reference

Conforms to NSObject
Declared in ORKStepViewController.h

The primary implementer of the ORKStepViewControllerDelegate protocol is the task view controller (ORKTaskViewController). The task view controller observes the messages of the protocol to correctly update its result property, and to control navigation through the task.

If you present step view controllers outside of a task view controller, it can be helpful to implement this protocol to facilitate navigation and results collection.

– stepViewController:didFinishWithNavigationDirection: required method

Tells the delegate when the user has done something that requires navigation, such as tap the Back or a Next button, or enter a response to a nonoptional survey question.

- (void)stepViewController:(ORKStepViewController *)stepViewController didFinishWithNavigationDirection:(ORKStepViewControllerNavigationDirection)direction

Parameters

stepViewController

The step view controller providing the callback.

direction

Direction of navigation requested.

Declared In

ORKStepViewController.h

– stepViewControllerResultDidChange: required method

Tells the delegate when a substantial change has occurred to the result.

- (void)stepViewControllerResultDidChange:(ORKStepViewController *)stepViewController

Parameters

stepViewController

The step view controller providing the callback.

Discussion

The result is always available in the step view controller. Although the result is continuously changing while the step view controller is active (because the time stamp in the result property is different each time it’s called), this method is called only when a substantive change to the result occurs, such as when the user enters a survey answer or completes an active step.

In your implementation of this delegate method, you can collect the value of result from the step view controller.

Declared In

ORKStepViewController.h

– stepViewControllerDidFail:withError: required method

Tells the delegate when a step fails due to an error.

- (void)stepViewControllerDidFail:(ORKStepViewController *)stepViewController withError:(nullable NSError *)error

Parameters

stepViewController

The step view controller providing the callback.

error

The error detected.

Discussion

A step view controller can use this method to report its failure to the task view controller. The task view controller sends the error to its delegate indicating that the task has failed (using ORKTaskViewControllerFinishReasonFailed). Note that recorder errors are reported by calling the ORKStepViewControllerDelegate method stepViewController:recorder:didFailWithError:.

Declared In

ORKStepViewController.h

– stepViewController:recorder:didFailWithError: required method

Tells the delegate when a recorder error has been detected during the step.

- (void)stepViewController:(ORKStepViewController *)stepViewController recorder:(ORKRecorder *)recorder didFailWithError:(NSError *)error

Parameters

stepViewController

The step view controller providing the callback.

recorder

The recorder that detected the error.

error

The error detected.

Discussion

Recorder errors can occur during active steps, usually due to the unavailability of sensor data or disk space in which to record results.

Declared In

ORKStepViewController.h

– stepViewControllerWillAppear:

Tells the delegate that the step view controller’s view is about to appear.

- (void)stepViewControllerWillAppear:(ORKStepViewController *)stepViewController

Parameters

stepViewController

The step view controller providing the callback.

Discussion

This method is called from the step view controller’s viewWillAppear: method. You can use this method to customize the appearance of the step view controller without subclassing it.

Declared In

ORKStepViewController.h

– stepViewControllerHasPreviousStep:

Asks the delegate whether there is a previous step.

- (BOOL)stepViewControllerHasPreviousStep:(ORKStepViewController *)stepViewController

Parameters

stepViewController

The step view controller providing the callback.

Return Value

YES if a Back button should be visible; otherwise, NO.

Discussion

If there is a previous step, the step view controller adds a Back button to its navigation item; if not, no Back button is added to the navigation item.

Declared In

ORKStepViewController.h

– stepViewControllerHasNextStep:

Asks the delegate whether there is a next step.

- (BOOL)stepViewControllerHasNextStep:(ORKStepViewController *)stepViewController

Parameters

stepViewController

The step view controller providing the callback.

Return Value

YES if there is a step following the current one; otherwise, NO.

Discussion

Depending on the result of the step, the step view controller can adjust the language for the Next button.

Declared In

ORKStepViewController.h