2015-12-04 3 views
-1

Как создать формат ответа с несколькими вариантами выбора с помощью Research Kit. Я знаю, что мне нужно использовать ORKTextChoiceAnswerFormat, но не могу найти код. Может ли любой орган помочь?Как создать формат ответа с несколькими вариантами выбора с помощью Research Kit?

ответ

1
// 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];