ios - 如何在一系列问题中后退或前进?
问题描述
我有一系列问题是字典中的关键。每个问题对应的选择是每个键的值。如果用户决定要跳过一个问题或返回一个问题,我希望用户能够出于导航原因跳过或返回一个问题。这是我的快速代码:
@IBAction func goNext(_ sender: Any) {
}
func nextQ(sender: UIButton) {
if sender == nextButton {
questionTitle.text = surveyQuestions[1]
}
}
var surveyQuestions = [String]()
func startSurvey() {
if surveyQuestions.isEmpty {
surveyQuestions = Array(SampleSurvey().surveyquestions.keys)
print(surveyQuestions)
}
let rand = Int(arc4random_uniform(UInt32(surveyQuestions.count)))
questionTitle.text = surveyQuestions[rand]
var choices = SampleSurvey().surveyquestions[surveyQuestions[rand]]!
print(choices)
print(choices.count)
print(surveyChoices.count)
surveyQuestions.remove(at: rand)
}
IBAction 是“跳过”按钮。我希望它的功能如下:按下按钮并将数组中的下一个问题呈现给用户。我还希望用户能够返回并再次向他们展示上一个问题以及相应的值/选择。我怎样才能实现这个所需的功能?
这是我当前功能的屏幕截图,当我单击屏幕底部的后退或下一步时,没有任何反应。我希望通过单击下一步来呈现新问题,或者通过单击返回来呈现旧问题以及相应的选项
解决方案
推荐阅读
- node.js - 如何使用 mongoose 在 mongodb 中使用动态字段搜索数据?
- java - 如果通过 JarLauncher 启动 Spring-boot 会忽略 log4j2.xml
- odbc - Sqitch 部署到雪花 DW 失败
- c# - 如何处理 API 审计
- python - Python:如何将字符串插入 .txt 文件中的特定位置?
- matlab - Matlab Countour Plot 带迹线
- android - 请求密钥时出现 IOException:使用 Google 登录时设备密钥响应无效
- nginx - CentOs Nginx 重定向 https://www 到 https://
- download - Snakemake - 下载数据的规则
- office-js - 在任务窗格 Office-addin 中访问外部网站