Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
in my app I want to have a uilabel in my mainview which displays a countdown from a chosen number of seconds. This shouldnt be too hard. But now comes the clue. I only want the timer to start the countown when there are no touch events at all. So every time the user clicks a button, changes to a different view or does anything else the timer should start counting down from the begining again.
How would you do this? How do I termine if there is a touch event anywhere in the app? Do I use NSTimer?
#pragma mark Touches -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { // touch started. [allTouches count] will tell how many touches if it matters NSSet *allTouches = [event allTouches]; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { // they released the touch ( stop timer? ) [myTimer invalidate]; }
#pragma mark Timer - (void)timerFired:(NSTimer *)timer{ // update label }
We have a few different sections here. The first is where we create and start our timer object. The second section is to detect touches (start, move and end), and the last is for the callback on the timer firing.
Hope that guides you in the right direction. =)
My Apps on AppStore : gScale (guitar scales reference), <a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=302865690" target=
Thank you! That really got me quite far. But how do I update the label constantly? I want the user to see the countdown. I guess I have to update the label every second. Just exactly how do you do that. Haven't found anything on that here. Thanks again!
Thank you! That really got me quite far. But how do I update the label constantly? I want the user to see the countdown. I guess I have to update the label every second. Just exactly how do you do that. Haven't found anything on that here. Thanks again!
Hi,
Though I am not an expert at IPHONE SDK,this may help..
a) start running a timer to update the lable for every second(as u required). b) As and when any touch is detected, invalidate the timer and set the countdown buffer to required value. c) If u find touch is ended, again start the timer for displaying countdown and its update.
Replies
We have a few different sections here. The first is where we create and start our timer object. The second section is to detect touches (start, move and end), and the last is for the callback on the timer firing.
Hope that guides you in the right direction. =)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeBut how do I update the label constantly? I want the user to see the countdown.
I guess I have to update the label every second. Just exactly how do you do that. Haven't found anything on that here.
Thanks again!
Wico - A powerful location based reminder
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThough I am not an expert at IPHONE SDK,this may help..
a) start running a timer to update the lable for every second(as u required).
b) As and when any touch is detected, invalidate the timer and set the countdown buffer to required value.
c) If u find touch is ended, again start the timer for displaying countdown and its update.
May this help.
Please reply ,if u find any helpful solution.
Thank u.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome