对于我正在实施的问题,我有 16 个图像,我想在 4 x 4 网格中呈现。
ORKImageChoice的文档表明“通常,图像选择显示在水平行中”,但我不希望这样。如何在网格中布局图像?
这是我的代码,它内联显示图像:
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)