【发布时间】:2021-12-25 18:39:48
【问题描述】:
我有一个显示当前图像的功能和两个按钮(上一个和下一个)来显示上一个图像或下一个图像。但是我的代码有一些错误。请帮忙。泰。
import UIKit
class ViewController: UIViewController {
func showImage() {
if count < photoCollection.count {
if let images = photoCollection[count] as? Dictionary<UIImage, String> {
photo.image = images.keys.first
Text.text = images.values.first
}
} else {
debugPrint("Failed!")
}
}
}
【问题讨论】:
-
你不应该使用字典。您应该使用数组来存储数据。
-
但是需要使用字典。
-
你确定它必须是一本字典吗?这似乎是个坏主意——字典是无序的。
标签: ios swift dictionary button uiimageview