0

对于我正在实施的问题,我有 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)  
4

1 回答 1

0

来自ResearchKit 的 GitHub 问题跟踪器的交叉发布。

图像选择答案格式目前不提供对此的支持。您需要对内部进行一些涉及的修改以支持这一点(您需要一种方法来指定网格需要多少列/行等)

我能想到的使用当前 RK 功能的解决方法是使用一个表单在同一个表单上显示多个单独的图像选择答案格式,一个用于网格的每一行。有关如何在表单中包含图像选择问题的示例代码,请参阅中的迷你表单示例。ORKTest

于 2016-03-01T12:07:25.210 回答