当我在模拟器中按nextImage1
时,我收到错误消息:
[Project_BodySwapp.ViewController nextImage:]:无法识别的选择器发送到实例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.
}
}
非常感谢任何帮助