iphone - Invalidate and release an NSTimer when popping a view (with a UINavigationController) -



iphone - Invalidate and release an NSTimer when popping a view (with a UINavigationController) -

i'm using uinavigationcontroller: in first view there uibutton pushes view using code

- (ibaction)gototrack:(id)sender { map *map2 = [[map alloc] initwithnibname:@"map" bundle:[nsbundle mainbundle]]; [self.navigationcontroller pushviewcontroller:map2 animated:yes]; [map2 release]; }

in sec view there map indicates position of object. object moving fast, need refresh position every second: i'm doing nstimer, calls method calculates new coordinates , refreshes map. ok, works fine, when user pops view (with usual button in navigationbar) sec view not released, because nstimer still working!

what can invalidate , release nstimer when user pops sec view? there methods called automatically? (i tried nothing)

thanks!

you can seek invalidating nstimer in -viewwilldisappear or viewdiddisappear.

viewwilldisappear:

this method called in response view beingness removed window or covered view. method called before view removed or covered , before animations configured.

subclasses can override method , utilize commit editing changes, resign first responder status of view, or perform other relevant tasks. example, might utilize method revert changes orientation or style of status bar made in viewdiddisappear: method when view first presented. if override method, must phone call super @ point in implementation.

have @ uiviewcontroller reference more details.

iphone uinavigationcontroller release nstimer invalidate

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -