如何使用Research Kit创建多选答案格式。我知道我必须使用ORKTextChoiceAnswerFormat
,但找不到一些代码。任何身体都能帮上忙吗?
// bool Question 1
ORKBooleanAnswerFormat *boolFormat = [ORKBooleanAnswerFormat new];
ORKQuestionStep *booleanStep1 = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierQ1"];
booleanStep1.title = @"Are you feeling ill?";
booleanStep1.answerFormat = boolFormat;
booleanStep1.optional = NO;
// choice Question1
ORKTextChoiceAnswerFormat *choice = [ORKTextChoiceAnswerFormat choiceAnswerFormatWithStyle:ORKChoiceAnswerStyleMultipleChoice textChoices:@[@"Cough",@"Sore throat",@"Runny or stuffy nose"]];
ORKQuestionStep *multipleStep = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierC1"];
multipleStep.title = @"Do you feel any symptoms given below?";
multipleStep.answerFormat = choice;
multipleStep.optional = NO;
// bool Question 2
ORKQuestionStep *booleanStep2 = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierQ2"];
booleanStep2.title = @"Do you feel problem in your eye?";
booleanStep2.answerFormat = boolFormat;
booleanStep2.optional = NO;
// choice Question2
ORKTextChoiceAnswerFormat *choice2 = [ORKTextChoiceAnswerFormat choiceAnswerFormatWithStyle:ORKChoiceAnswerStyleMultipleChoice textChoices:@[@"Eye Redness",@"Eye Itching",@"Discharge (usually watery or mucous-like)",@"Feels like there is sand in the eye.",@"Crusting over of the eyelid."]];
ORKQuestionStep *multipleStep2 = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierC2"];
multipleStep2.title = @"Do you feel any symptoms given below?";
multipleStep2.answerFormat = choice2;
multipleStep2.optional = NO;
// bool Question 3
ORKQuestionStep *booleanStep3 = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierQ3"];
booleanStep3.title = @"Do you feel problem in your stomach?";
booleanStep3.answerFormat = boolFormat;
booleanStep3.optional = NO;
// choice Question3
ORKTextChoiceAnswerFormat *choice3 = [ORKTextChoiceAnswerFormat choiceAnswerFormatWithStyle:ORKChoiceAnswerStyleMultipleChoice textChoices:@[@"Diarrhea",@"Abdominal Pain",@"Nausea",@"Vomiting"]];
ORKQuestionStep *multipleStep3 = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierC3"];
multipleStep3.title = @"Do you feel any symptoms given below?";
multipleStep3.answerFormat = choice3;
multipleStep3.optional = NO;
// Present the task view controller.
ORKOrderedTask *task =
[[ORKOrderedTask alloc] initWithIdentifier:@"identifier8" steps:@[booleanStep1,multipleStep,booleanStep2,multipleStep2,booleanStep3,multipleStep3]];
ORKTaskViewController *taskViewController =
[[ORKTaskViewController alloc] initWithTask:task taskRunUUID:nil];
taskViewController.delegate = self;
[self presentViewController:taskViewController animated:YES completion:nil];