2017-02-24 1 views
0

imageview를 회전하려고하는데 작동 중이었지만 다른 화면 애니메이션에서 해당 화면을로드 할 때 작동하지 않습니다.애니메이션이 작동하지 않습니까?

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

}

애니메이션을 다음하는 것은 개별적으로는 작동하고 직장까지하지 않는 것처럼 내가 LoadingRequestViewController를 호출

.

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

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

답변

0

viewwillAppear에 추가하십시오. 그것은 잘 작동합니다!

관련 문제