iphone - stop and restore method -


I am using this function to create the movement, how can I stop the movement? I want to restore it to the starting point Thank you. [NSTimer Scheduled timer with interval: 0.02 goals: self selector: @sillector (shaffloanimimer) userInfo: zero repeats: yes]; - (zero) resize antonymer {jb.center = CGPointMake (jb.center.x + pos1.x, jb.center.y + pos1.y); If (jb.center.x> 60 || jb.center.x & lt; 0) pos1.x = -pos1.x; If (jb.center.y> 240 || jb.center.y & lt; 100) pos1.y = -pos1.y;}

At some point you should invalidate the timer. You have to store its reference to do this:

In your header file:

  @ class myClass: NSObject {.... NSTimer * timer; CGPpoint Basics; ...} @property (non-standard, readwrite, assign) NSTIMER * timer; @protecti (nonomatic, readwrite) CGPint original page;  

In your implementation file:

  self.originalPoint = jb.position; Self.timer = [NSTimer Scheduled timer with time interval ...  

As a later point:

  [self.timer invalid]; Self.timer = Zero; // very important, jb.position = self.originalPoint; to avoid dangling signals;  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

jquery - SimpleModal Confirm fails to submit form -