的值
我一直收到此错误:
不能将类型为"[UIImage]"的值下标为"((" 的索引
这是我的代码:
let images: [UIImage] = [
UIImage(named: "profilePicture.jpg")!,
UIImage(named: "back3.jpg")!,
UIImage(named: "back1.jpg")!]
var index = 0
let animationDuration: TimeInterval = 0.25
let switchingInterval: TimeInterval = 3
let chnagingImageView = UIImageView()
override func viewDidLoad() {
chnagingImageView.frame = CGRect(x: 0, y: 300, width: view.frame.width, height: 200)
view.addSubview(chnagingImageView)
chnagingImageView.image = images[index += 1]
animateImageView()
}
错误发生在以下行中:
chnagingImageView.image = images[index += 1]
任何帮助将不胜感激。请注意,我看到了另一个问题,这只是游乐场的问题,它提供的解决方案只是刷新代码。但是,这不起作用,我仍然收到错误。
let images: [UIImage] = [
UIImage(named: "profilePicture.jpg")!,
UIImage(named: "back3.jpg")!,
UIImage(named: "back1.jpg")!]
var index = 0
let animationDuration: TimeInterval = 0.25
let switchingInterval: TimeInterval = 3
let chnagingImageView = UIImageView()
override func viewDidLoad() {
chnagingImageView.frame = CGRect(x: 0, y: 300, width: view.frame.width, height: 200)
view.addSubview(chnagingImageView)
for myimage in images.count-1
{
if myimage==1
{
chnagingImageView.image = images[myimage]
}
}
}
将其更改为
index += 1
chnagingImageView.image = images[index]
因为index += 1
返回()
=>数组无法获取索引类型为 ()