如何指定用户在使用谓词导航规则的步骤中点击“跳过”按钮时将重定向到的步骤?
现在它重定向到任务的开始。
以下是可选步骤:
// multiple choices question
let multipleQuestionsStepTitle = "what is your gender ?"
let textChoices = [ORKTextChoice(text: "Female", value: 0),
ORKTextChoice(text: "Male", value: 1),
ORKTextChoice(text: "idk", value: 2)]
let multipleQuestionsAnswerFormat: ORKTextChoiceAnswerFormat = ORKAnswerFormat.choiceAnswerFormatWithStyle(.SingleChoice, textChoices: textChoices)
let multipleQuestionsStep = ORKQuestionStep(identifier: "TextChoiceQuestionStep", title: multipleQuestionsStepTitle, answer: multipleQuestionsAnswerFormat)
multipleQuestionsStep.optional = true
steps += [multipleQuestionsStep]
以下是导航规则:
let task = ORKNavigableOrderedTask(identifier: "SurveyTask", steps: steps)
var predicateRule: ORKPredicateStepNavigationRule
let predicateFemale: NSPredicate = ORKResultPredicate.predicateForChoiceQuestionResultWithResultSelector(ORKResultSelector(resultIdentifier: "TextChoiceQuestionStep"), expectedAnswerValue: 0)
// invert of previous predicate
let predicateNotFemale: NSPredicate = NSCompoundPredicate.init(notPredicateWithSubpredicate: predicateFemale)
predicateRule = ORKPredicateStepNavigationRule.init(resultPredicates: [predicateNotFemale], destinationStepIdentifiers: ["IntroStep"], defaultStepIdentifier: "ImageChoiceQuestionStep", validateArrays: false)
task.setNavigationRule(predicateRule, forTriggerStepIdentifier: "TextChoiceQuestionStep")
我认为如果我们跳过这一步,我们会重定向到defaultStepIdentifier
,但事实并非如此。
如果我们有导航规则,我在文档中没有找到关于将optional设置为false的内容,那么也许某人有解决方法可以做到这一点?