For a question I am implementing I have 16 images that I would like to present in a 4 x 4 grid.
The documentation for ORKImageChoice indicates that "typically, image choices are displayed in a horizontal row" , but I don't want that. How can I layout the images in a grid?
Here is my code thats is displaying the images inline:
let pamTuples = [
(UIImage(named: "1_1")!, "1"),
(UIImage(named: "1_2")!, "2"),
(UIImage(named: "1_3")!, "3"),
(UIImage(named: "1_4")!, "4"),
(UIImage(named: "2_1")!, "5"),
(UIImage(named: "2_2")!, "6"),
(UIImage(named: "2_3")!, "7"),
(UIImage(named: "2_4")!, "8"),
(UIImage(named: "3_1")!, "9"),
(UIImage(named: "3_2")!, "10"),
(UIImage(named: "3_3")!, "11"),
(UIImage(named: "3_4")!, "12"),
(UIImage(named: "4_1")!, "13"),
(UIImage(named: "4_2")!, "14"),
(UIImage(named: "4_3")!, "15"),
(UIImage(named: "4_4")!, "16")
]
let imageChoices : [ORKImageChoice] = pamTuples.map {
return ORKImageChoice(normalImage: $0.0, selectedImage: nil, text: $0.1, value: $0.1)
}
let pamAnswerFormat: ORKImageChoiceAnswerFormat = ORKAnswerFormat.choiceAnswerFormatWithImageChoices(imageChoices)
let pamQuestionStep = ORKQuestionStep(identifier: "mood image", title: pamQuestionStepTitle, answer: pamAnswerFormat)