problem with animateWithDuration on landscape mode

  1. 4 years ago

    if I build project with Portrait modes only - animation works perfectly, but if I build with landscape modes only it does not animate, just shows end result of animation.

    import Foundation 
    import AVFoundation 
    import CoreMedia 
    import UIKit 
    import QuartzCore
    
    class ViewController: UIViewController {
    
    var myLoadingView:UIView!
    
    let screenSize: CGRect = UIScreen.mainScreen().bounds
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    
        var halfWidth = screenSize.width/2-200
        var halfHeigth = screenSize.height/2-100
        let loadingWidth:Int = 200
        let loadingHeigth:Int = 100
        let circleMaxSize = 60
        let circleMinSize = 20
    
        self.myLoadingView = UIView(frame: CGRect(x:0,y:0,width:screenSize.width,height:screenSize.height))
        self.myLoadingView.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
    
    
    
    
        var myImageView = UIImageView(frame: CGRect(x:halfWidth,y:halfHeigth,width:1,height:1))
    
        //myImageView.backgroundColor = UIColor.greenColor()
        var myImage = UIImage(named: "circle")
        myImageView.image = myImage
        myImageView.alpha = 0
        self.myLoadingView.addSubview(myImageView)
    
    
    
    
        var myImageView2 = UIImageView(frame: CGRect(x:halfWidth+50,y:halfHeigth,width:1,height:1))
        var myImage2 = UIImage(named: "circle")
    
        myImageView2.image = myImage2
        myImageView2.alpha = 0
        self.myLoadingView.addSubview(myImageView2)
    
        //first circle
        //sleep(1)
    
    
    
    
        var myImageView3 = UIImageView(frame: CGRect(x:halfWidth+50,y:halfHeigth,width:1,height:1))
        var myImage3 = UIImage(named: "circle")
    
        myImageView3.image = myImage3
        myImageView3.alpha = 0
        self.myLoadingView.addSubview(myImageView3)
    
    
    
        self.view.addSubview(self.myLoadingView)
        //first circle
    
        UIView.animateWithDuration(1.0, animations: {
            myImageView.alpha = 1.0
            myImageView.frame = CGRect(x: halfWidth, y: halfHeigth, width: 100, height: 100)
            myImageView.backgroundColor = UIColor.greenColor()
            }, completion: {
                animationFinished in
                println(">>> Animation done.")
        })
        UIView.animateWithDuration(5.0, animations: {
            myImageView2.alpha = 1.0
            myImageView2.frame = CGRect(x: halfWidth+30, y: halfHeigth, width: 80, height: 80)
            myImageView2.backgroundColor = UIColor.redColor()
            }, completion: {
                animationFinished in
                println(">>> Animation done.")
        })
    
    
        UIView.animateWithDuration(10.0, animations: {
            myImageView3.alpha = 1.0
            myImageView3.frame = CGRect(x: halfWidth+80, y: halfHeigth, width: 50, height: 50)
            myImageView3.backgroundColor = UIColor.grayColor()
            }, completion: {
                animationFinished in
                println(">>> Animation done.")
        })
    
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    }

or Sign Up to reply!