ios - Run animation until a button is pressed -


I am trying to create an app in which the animation should run until a button is pressed. I have tried to use infinite loop but my app is not running with that loop at all. It's taking all the memory, I tried to call again when I completed the same function, but this process consumes 100% of CPU too.

Can you please guide me what I should do here

The landscape is in the background of the scene, the animation should be played continuously until the button is pressed. Another view will be opened when the button will be pressed and then the second animation keeps running until continuous until some buttons are pressed. After my code is:

  function unlimitedLoop () {rotation = true self.ProcurementSupport.transform = CGAffineTransformMakeTranslation (0, 100) self.ProcurementSupport.hidden = false UIView.animateWithDuration (3, Delay: 2, usingSpringWithDamping: 2, initialSpringVelocity: 2, options: zero, animation: {// self.EquipmentSupport.hidden = true on X: NSTimeInterval = 2 springWithDelay (2, X, {self.ProcurementSupport.transform = CGAffineTransformMakeTranslation (0,0) ) self.EquipmentSupport.transform = CGAffineTransformMakeTranslation (1000,0) x = x + 2} springWithDelay (2, X, {self.EquipmentSupport.transform = CGAffineTransformMakeTranslation (0,100) x = x + 2} springWithDelay (2, X, {Self.ProcurementSupport.transform = CGAffineTransformMakeTranslation (1000,0) self.EquipmentSupport.transform = CGAffineTransformMakeTranslation (0,0) x = x + 2} spring withdale (2, x, {self.ProcurementSupport.transform = CGAffineTransformMakeTranslation (0, 100)) x = x + 2})}, complete: {end in itself. Unregulated LoopAgain ()}}    

Custom by creating the infinite loop you need To run this function on a separate thread, it is best to stop the thread for a short time, next to the loop, for example, to know about 60 / FPS 1.0 / 60.0 Call for sleeping. Another problem in this approach is that when a parameter changes on a new thread view system, it will call back to the "Display call requirements" refresh on the main thread, in no case do you create such a function Should and call it made in an animation like you did, you have to do the animation itself.

A better approach is usually a type of timer or a display link in your case. This item will trigger every time so that the display should be done again so that it is perfect for your animation. These calls are usually already on the main thread, so you do not need anything else then the calls made in an animation should be avoided.

Nevertheless, a recursive type must be used in a manner. Every time you update the animation, you call the same update method after a while (1.0 / 60.0) ...

Even though your endless loop just executes and all The processor takes the power, but no other method is executed because of it so that you can not see the results. You need to let the system run other methods between the frames (update call), either stop executing for some time after each update, or keep it on a separate thread. Let's fix

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -