0
J'essaye de faire pivoter une imageview et qui fonctionnait mais quand je charge cet écran d'une autre animation d'écran ne fonctionne pas.L'animation ne fonctionne pas?
class LoadingRequestViewController: UIViewController ,UICollectionViewDelegate,GMSMapViewDelegate, CLLocationManagerDelegate {
//UI OutletControls
@IBOutlet weak var loadingImg: UIImageView!
@IBOutlet var mapView: GMSMapView!
@IBOutlet weak var containerView: UIView!
//UI OutletControls
override func viewDidLoad() {
super.viewDidLoad()
loadingImg.startRotating()
}
func TimerStoppedTrue() {
TimerStopped = true
NSLog("TimerStopped\(TimerStopped)")
}
@IBAction func CancelHireAction(sender: AnyObject) {
self.timer.invalidate()
self.CancelHire(self.HireID)
}
}
extension UIView {
func startRotating(duration: Double = 1) {
let kAnimationKey = "rotation"
if self.layer.animationForKey(kAnimationKey) == nil {
let animate = CABasicAnimation(keyPath: "transform.rotation")
animate.duration = duration
animate.repeatCount = Float.infinity
animate.fromValue = 0.0
animate.toValue = Float(M_PI * 2.0)
self.layer.addAnimation(animate, forKey: kAnimationKey)
}
}
func stopRotating() {
let kAnimationKey = "rotation"
if self.layer.animationForKey(kAnimationKey) != nil {
self.layer.removeAnimationForKey(kAnimationKey)
}
}
}
quand j'appeler LoadingRequestViewController comme animation suivante ne work.But individuellement, il travaille.
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("LoadingSTBID") as! LoadingRequestViewController
self.presentViewController(vc, animated: true, completion: nil)