在xcode中运行动画后,我需要将UIImage更改为不同的静态图像
因此,在动画完成后,didReceiveMemoryWarning下的代码似乎不会被调用。我想让动画做的是,当按下UIbutton时,它会显示一系列的UIImages,然后在重复6次计数后,它会在随机静态图像上停止,基于:在xcode中运行动画后,我需要将UIImage更改为不同的静态图像,xcode,swift,animation,static,uiimage,Xcode,Swift,Animation,Static,Uiimage,因此,在动画完成后,didReceiveMemoryWarning下的代码似乎不会被调用。我想让动画做的是,当按下UIbutton时,它会显示一系列的UIImages,然后在重复6次计数后,它会在随机静态图像上停止,基于: @IBAction func playRoundTapped(sender: UIButton) { let firstRandomNumber = arc4random_uniform(2) + 1 let firstCardString:Str
@IBAction func playRoundTapped(sender: UIButton) {
let firstRandomNumber = arc4random_uniform(2) + 1
let firstCardString:String = String(format: "side%i", firstRandomNumber)
self.firstDiceImageView.image = UIImage(named: firstCardString)
}
但是,由于某些原因,每次动画完成时,它都会返回到“card_default”静态图像,而不是“side%i”随机图像
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//Setting UIImages to Default
self.firstDiceImageView.image = UIImage(named: "card_default")
self.secondDiceImageView.image = UIImage(named: "card_default")
self.thirdDiceImageView.image = UIImage(named: "card_default")
self.forthDiceImageView.image = UIImage(named: "card_default")
//Animation For Loop
for i in 1...4
{
myImages.append(UIImage(named: "\(i)")!)
}
firstDiceImageView.animationImages = myImages
firstDiceImageView.animationRepeatCount = 6
firstDiceImageView.stopAnimating()
secondDiceImageView.animationImages = myImages
secondDiceImageView.animationRepeatCount = 6
thirdDiceImageView.animationImages = myImages
thirdDiceImageView.animationRepeatCount = 6
forthDiceImageView.animationImages = myImages
forthDiceImageView.animationRepeatCount = 6
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func playRoundTapped(sender: UIButton) {
let firstRandomNumber = arc4random_uniform(2) + 1
let firstCardString:String = String(format: "side%i", firstRandomNumber)
self.firstDiceImageView.image = UIImage(named: firstCardString)
}
您希望button方法如何自己被调用?@IBAction func playRoundTapped(发件人:UIButton)这就是button方法吗?我对编码很陌生是的。如果希望调用其中的代码,请将该代码放在imegeview动画代码下。