【问题标题】:Creating response to answering quiz questions in a table在表格中创建对回答测验问题的响应
【发布时间】:2013-04-24 15:07:31
【问题描述】:

我正在为医学生创建一个应用程序,其中一个视图是一种测验模式,它随机生成带有答案选项的表格视图的测验问题。在当前阶段,用户从表格视图中选择一个答案,表格视图下方的文本字段告诉他们他们是否正确。 我想做的是,当用户单击答案时,如果答案正确,则表中选定的答案会突出显示为绿色。如果答案是错误的,选择的答案会变成红色,表格中的正确答案会变成红色。任何人都知道是否可以在同一张表中使用不同的选择背景颜色(以及所描述的逻辑是否可能)?

【问题讨论】:

    标签: ios ipad


    【解决方案1】:

    这应该可以解决问题,注意它没有经过测试:

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        if(indexPath.row != self.correctAnswerRow)
        {
            UITableViewCell *wrongCell = [tableView cellForRowAtIndexPath:indexPath];
            [wrongCell setBackgroundColor:[UIColor redColor]];
        }
    
        UITableViewCell *correctCell = [tableView cellForRowAtIndexPath:
    [NSIndexPath indexPathForRow:self.correctAnswerRow inSection:indexPath.section]];
        [correctCell setBackgroundColor:[UIColor greenColor]];
    }
    

    【讨论】:

      猜你喜欢
      • 2020-09-04
      • 2021-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多