0
即時プログラミングで秒を開始すると、第1ビューコントローラのアニメーションを停止する方法。最初のビューコントローラでアニメーションを停止する関数を作成しました。私はそれを2番目のView Controllerで呼びたいと思っています。最初のビューコントローラで第2回目の起動時に第1ビューコントローラのアニメーションを停止します。
func stopAni(){
self.resultView.stopAnimating()
ButtonAudioPlayer.stop()
ButtonAudioPlayer1.stop()
ButtonAudioPlayer2.stop()
ButtonAudioPlayer3.stop()
ButtonAudioPlayer4.stop()
ButtonAudioPlayer5.stop()
ButtonAudioPlayer6.stop()
第2のビューコントローラでこの関数を呼び出す方法がわかりません。することができます、あなたの第2のビューコントローラで
class FirstViewController : UIViewController, StopAnimationDelegate{
//..... here code
func stopAnimations(){
//Stop your animations or call your method stopAni here.
}
//.... here more code
@IBAction func openSecondViewController(sender:UIButton){
self.performSegueWithIdentifier("segue_first_second",sender:nil)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "segue_first_second"{
let secondViewController = segue.destinationViewController as! SecondViewController
secondViewController.delegate = self
}
}
}
:
protocol StopAnimationDelegate{
func stopAnimations()
}
次に、あなたの最初のビューコントローラ上で、あなたがこのプロトコルを採用するつもりだ:
私はあなたが提案しSWIFTコードを使用するが、それはありますうまくいきません! @JoséRoberto Abreu – John
@Johnサンプルプロジェクトをアップロードして確認できますか? –