gpt4 book ai didi

arrays - 在按下按钮滚动数组时,我的应用程序崩溃了

转载 作者:可可西里 更新时间:2023-11-01 01:18:59 24 4
gpt4 key购买 nike

当我在模拟器中按下 nextImage1 时,我收到一条错误消息:

[Project_BodySwapp.ViewController nextImage:]: unrecognized selector sent to instance 0x7ffe4660a1e0'

import UIKit

class ViewController: UIViewController {

var imageNames1 = ["doghead","uk"]
var imageNames2 = ["macawLower","us"]
var pickedImage = String()
var currentImage = 0

@IBOutlet weak var displayImage: UIImageView!
//212x138
@IBOutlet weak var displayImage2: UIImageView!
//212x334


//BUTTON FUNCTIONALITY
//UPPER
@IBAction func randomizeImage(_ sender: Any) {
displayImage.image = UIImage(named: (produceRandomValue(imageNames1)))
}

@IBAction func nextImage1(_ sender: Any) {
currentImage += 1
displayImage.image = UIImage(named: imageNames1[currentImage])
}

@IBAction func previousImage1(_ sender: Any) {


}



//LOWER
@IBAction func randomizeImage2(_ sender: Any) {

displayImage2.image = UIImage(named: (produceRandomValue(imageNames2)))
}



func randomFromZero(to number: Int) -> Int {
return Int(arc4random_uniform(UInt32(number)))
}

func produceRandomValue(_ array: [String]) -> String {
let randomIndex = randomFromZero(to: array.count)
let pickedImage = imageNames1[randomIndex]
return pickedImage
}


override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}


}

任何帮助将不胜感激

最佳答案

您的按钮操作 touchUpInside 已设置为 nextImage 但在您的代码中您没有。你有 nextImage1 代替。重新检查连接检查器。

enter image description here

关于arrays - 在按下按钮滚动数组时,我的应用程序崩溃了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44813338/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com