UIImageView:致命错误:数组索引超出范围

时间:2014-10-08 16:31:02

标签: ios swift uiimageview uiimage

我试图重复显示图片,但我发现了超出范围的错误。

这是我的代码:

@IBOutlet weak var im: UIImageView!
var images = ["page003.png","page004.png","page005.png","page006.png"]
var indice = 0
 @IBAction func n(sender: AnyObject) {
    indice++
    if indice == images.count
    {
    indice == 0
    }
    im.image = UIImage(named: (images[indice]))
}

1 个答案:

答案 0 :(得分:0)

indice == 0替换为indice = 0