2017-02-24 7 views
0

イメージビューを回転しようとしていますが、動作していましたが、別のスクリーンアニメーションからその画面を読み込むと機能しません。アニメーションが動作しませんか?

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) 
    } 
} 

}

以下のアニメーションは、それが働いている個別work.Butしないように私はLoadingRequestViewControllerを呼び出すとき。

let storyboard = UIStoryboard(name: "Main", bundle: nil) 
    let vc = storyboard.instantiateViewControllerWithIdentifier("LoadingSTBID") as! LoadingRequestViewController 

    self.presentViewController(vc, animated: true, completion: nil) 

答えて

0

viewwillAppearに追加してみてください。それは正常に動作するはずです!

関連する問題