ImageView
複数のビュー コントローラーを持つプロジェクト用に、アニメーション イメージをビルドしたいと考えています。インストラクターが見たすべてのチュートリアルでは、アニメーション ビューを追加して単一のViewController
. 私はコーディングにかなり慣れていないので、デモを作成しています。
以下のコードをViewController.swift
単一のView Controllerプロジェクトに適用してテストしましたが、動作しますが、複数のVCでは失敗します。VC.swift
以下にコードを掲載しました。
単一のView Controllerの作業コード:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var penjulumLogo: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
penjulumLogo.animationImages = [
UIImage(named: "Storing3dot.png")!,
UIImage(named: "Storing2dot.png")!,
UIImage(named: "Storing1dot.png")!,
UIImage(named: "Storing0dot.png")!,
UIImage(named: "Encrypted3dot.png")!,
UIImage(named: "Encrypted2dot.png")!,
UIImage(named: "Encrypted1dot.png")!,
UIImage(named: "Encrypted0dot.png")!,
UIImage(named: "Almost3dot.png")!,
UIImage(named: "Almost2dot.png")!,
UIImage(named: "Almost1dot.png")!,
UIImage(named: "Almost0dot.png")!,
UIImage(named: "monies3dot.png")!,
UIImage(named: "monies2dot.png")!,
UIImage(named: "monies1dot.png")!,
UIImage(named: "monies0dot.png")!,
]
penjulumLogo.animationDuration = 3
penjulumLogo.startAnimating()
}
}
複数のView Controllerで動作しないコールド(penjulumLogo.animatedImagesの次のエラー:
「スレッド 1: EXC_BAD_INSTRUCTION (コード = EXC_I386_INVOP、サブコード = 0x0)):
import UIKit
class ViewController: UIViewController {
let transitionManager = TransitionManager()
@IBOutlet weak var penjulumLogo: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
penjulumLogo.animationImages = [
UIImage(named: "Storing3dot.png")!,
UIImage(named: "Storing2dot.png")!,
UIImage(named: "Storing1dot.png")!,
UIImage(named: "Storing0dot.png")!,
UIImage(named: "Encrypted3dot.png")!,
UIImage(named: "Encrypted2dot.png")!,
UIImage(named: "Encrypted1dot.png")!,
UIImage(named: "Encrypted0dot.png")!,
UIImage(named: "Almost3dot.png")!,
UIImage(named: "Almost2dot.png")!,
UIImage(named: "Almost1dot.png")!,
UIImage(named: "Almost0dot.png")!,
UIImage(named: "monies3dot.png")!,
UIImage(named: "monies2dot.png")!,
UIImage(named: "monies1dot.png")!,
UIImage(named: "monies0dot.png")!,
]
penjulumLogo.animationDuration = 3
penjulumLogo.startAnimating()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// this gets a reference to the screen that we're about to transition to
let toViewController = segue.destinationViewController as UIViewController
// instead of using the default transition animation, we'll ask
// the segue to use our custom TransitionManager object to manage the transition animation
toViewController.transitioningDelegate = self.transitionManager
}
@IBAction func unwindToViewController(segue: UIStoryboardSegue) {
}
// we override this method to manage what style status bar is shown
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return self.presentingViewController == nil ? UIStatusBarStyle.Default : UIStatusBarStyle.LightContent
}
@IBAction func returnsegue(sender: UIStoryboardSegue) {
}
}