nstimer

How to repeatedly call a method (reload…) with a timer to animate a transition

核能气质少年 提交于 2019-12-13 08:58:58
问题 I implemented corePlot in my xcode project. I'm trying to "explode" a slice of the pie chart with animation. Here is the method I'm using: - (void)radialOffsetForPieChart:(CPTPieChart *)pieChart recordIndex:(NSUInteger)idx { if (myIndex == idx) { return 20; } return 0; } I have another method which calls [pieChart reloadRadialOffset]; . For example: - (void)thisMethod { [pieChart reloadRadialOffset]; } How can I animate the reloadRadialOffsets ? 回答1: I just added an example to the "Simple Pie

Objective c - NSTimer, CADisplayLink, Thread

二次信任 提交于 2019-12-13 07:37:24
问题 I'm currently making a little game with a countdown timer. I use an NSTimer, you can get extra time or less time, depends on your action. When I'm adding or removing seconds to my timer I have an issue with the time label. The issue is due to me, I'm calling my method timerAction, who set the new time in the label when I'm adding or removing time and then the NSTimer is calling the method too. If I don't call timerAction, I must wait 1 second to refresh the label with NSTimer. So, what should

How to take 30 screenshots in a second in an iOS device?

纵饮孤独 提交于 2019-12-13 06:12:19
问题 In my iOS app, I am using NSTime to invoke a method which takes screenshot of the device screen. I am taking 30 screenshots per second. On simulator its working fine (as the processor of Mac is far more powerful than iPad). But it takes less number of screenshots in actual device. How can I do this? Any reliable alternative for timer? Please help 来源: https://stackoverflow.com/questions/16982374/how-to-take-30-screenshots-in-a-second-in-an-ios-device

Seconds to - Minutes - Hours - Milliseconds

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 06:06:21
问题 I'm using the NSTimer, with this code: - (IBAction)start:(id)sender { MainInt = 0; timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countup) userInfo:nil repeats:YES]; } How can I display milliseconds and minutes also? Didn't find any simple yet working method. 回答1: For milliseconds use: timer = [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(countup)userInfo:nil repeats:YES]; For minutes use: timer = [NSTimer

Swift NSTimer and IBOutlet Issue

拜拜、爱过 提交于 2019-12-13 05:00:07
问题 I'm using NSTimer to update an image's position on the screen to give the illusion of movement. It's a flappy bird clone I'm creating to learn Swift. Anyway, I'm also updating an outlet by displaying an incrementing Int as the score. However, every time I update the Int and the corresponding outlet, the images on the screen reset to their starting point (bird and tubes). Very odd. Has anyone else come across this? What am I doing wrong? @IBOutlet weak var tube1: UIImageView! @IBOutlet weak

NSTimer in background mode using locationManager delegate (“Cheat way”) SWIFT

倾然丶 夕夏残阳落幕 提交于 2019-12-13 03:37:15
问题 I have a function that I want to run in the app background mode and be executed at least every minute to check for wifi connection and to make decisions. I am using locationManager delegate so I can run my NSTimer in the background. However the location manager is consuming a lot of battery power. This app is not for apple release. However I am looking for more efficient settings for location manager so it will not be that power hungry or maybe any other good ideas?. The current settings that

How to reset a timer in Objective C?

冷暖自知 提交于 2019-12-13 02:50:00
问题 I create a counter in this app that it starts when I click a button and stops when I click at the same button. The problem is that when I start again, the label that displays the count does not reset it keeps the counting from where it stopped. So any one could help me?? - (void)timerTick:(NSTimer *)timer { _lblCounter.text = @"0:00:00"; double seconds = 0.0; double minutes = 0.0; double hours = 0.0; ticks += 1.0; seconds = fmod(ticks, 60.0); minutes = fmod(trunc(ticks / 60.0), 60.0); hours =

How to reset NSTimer for touch , touch move in ios

梦想与她 提交于 2019-12-13 02:37:11
问题 I am working on app in which i have to hide control button after 3 second so i write code using NSTimer and Touch began and it work but problem is that when i touch again with on any another button than my timer is not reset and even if i move my touch example like drag. If i drag or move touch it should reset the timer but it won't. I found that this implementation work if i continuously touch on other area (but it is not working on Control button) IF i continuously touch control button

How to stop timer when user goes back to previous view

社会主义新天地 提交于 2019-12-13 00:52:48
问题 I have problem with my timer. In my game view in viewDidLoad I have: sixtySecondTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0/1.0) target:self selector:@selector(changeValue) userInfo:nil repeats:YES]; Next I have changeValue method: - (void) changeValue { timerInt += 1; NSLog(@"TimerInt2 = %d", timerInt); NSString *string = [NSString stringWithFormat:@"%d", timerInt]; labelTimer.text = string; } And I go to previous view using: - (IBAction)backView:(id)sender { timerInt = 0; [self

NSTimer Pause not working

早过忘川 提交于 2019-12-12 21:45:36
问题 I have setup three buttons with start , stop , pause . and given controls to NSTimer to calculates.start stop button works fine gives me the start and stop time but pause button does not gives me accurate time .it actually pause time ..but start again it adds the paused timed and disp[ay. supoose i pause at 5 second of start and wait for 5 sec then press start...it should display 5 ...but displaying 10.. -(void)start:(NSTimer *)timer { if(_timer==nil) { startDate =[NSDate date]; _timer=