ios - 我想在按右键时浏览数组,按左键时反转数组
问题描述
此代码针对数组中的下一项运行,但是当 leftButtonWasClciked 时,它会给出错误
@IBAction func rightButtonWasClicked(_ sender: Any) {
NTimeLabel.text = NTimeArrayRemasterd[currentIndex] // Set the text to the element at currentIndex in the array
currentIndex = currentIndex + 1 == NTimeArrayRemasterd.count ? 0 : currentIndex + 1 // Increment currentIndex
}
@IBAction func leftButtonWasClicked(_ sender: Any) {
NTimeLabel.text = NTimeArrayRemasterd[currentIndex] // Set the text to the element at currentIndex in the array
currentIndex = currentIndex - 1 == NTimeArrayRemasterd.count ? 0 : currentIndex - 1 // Decrement currentIndex
}
按下左右按钮时正确导航
解决方案
推荐阅读
- php - PHPUnit 测试未使用带有 SQLite 数据库的 laravel 6.0 运行
- javascript - 如何在 Jinja2 中动态设置 HTML 表单操作 url?
- python - 我试图替换字符串中的所有字符,但它仍然没有按预期工作?
- python - 如何在 Snakemake 规则中使用 dict 值和键
- list - Ocaml 将值附加到数组
- scala - 未找到合并策略
- asp.net - 如何在 angularJs 中添加 WebApi 标头
- flutter - 在 Flutter 中展开部分
- web-scraping - Scrapy Spider 如何避免当前页面和下一页之间的无限循环
- php - wordpress 网站加载时显示错误