tags:

views:

33

answers:

2

hi i am new to iphone. what i am doign is displaying 20 images as grid and by selecting image it is displayed on imageview after 4 sec it will come back to main screen,for that i am using timer it works fine but there is a small problem with out selecting image the timer is continually running.if i am selecting button on 2 sec late then with in remaining 2 sec it will come back how can i solve this pls help me

+1  A: 

Instead of having the timer continuously running, only start it when the user selects an image. That way you get the full 4 seconds. Also, make sure you set it not to repeat.

Jasarien
how can i set it and where can i place it
Jeyavel
A: 

In the selector you're calling with your timer, you need to invalidate that timer. That means you need to assign the timer to a property in your view controller, so you can talk about it later. So say you've got an ivar of NSTimer *backTimer, then in the method that the timer calls, you'll say [backTimer invalidate], and that timer will go away.

You should also invalidate it when somebody backs out of the "full image" view. Probably in -viewDidUnload or -viewDidDissapear.

Dan Ray