I have a slider with 96 slots and I need to moves slider step by step from 0 to 95 in 60 seconds. Should I use NSTimer with interval (60/96) and 96 repeats or there is a better solution for this?
Moving slider during a certain time
667 Views Asked by stalk At
2
There are 2 best solutions below
1
NANNAV
On
aTimer = [NSTimer timerWithTimeInterval:(1.0) target:self selector:@selector(timerFired:) userInfo:nil repeats:YES];
NSRunLoop *runner = [NSRunLoop currentRunLoop];
[runner addTimer:aTimer forMode: NSDefaultRunLoopMode];
- (void)timerFired:(NSTimer*)theTimer {
slider.maximumValue=totaltime;
if(slider.value ==totaltime)
{
[theTimer invalidate];
//terminate the loop
}
else
{
slider.value=slider.value+1;
}
}
//timer runs continuously run if condition is true
Related Questions in OBJECTIVE-C
- How to control the volume of an iPhone programmatically in objective-c
- Occasional crash at NSURLSessionDataTask dataTaskWithRequest:completionHandler:
- How to set value the descriptor of iOS BLE in Objective-C?
- Unexpected #selector() Behavior in Swift-Objective-C Interop?
- In what context can we use an unqualified #selector() expression in Swift?
- AVPictureInPictureController crashes during initialization
- How to use pow() in Objective-C?
- How to change the image on the MGSwipeButton in MGSwipeTableCell
- Using sort descriptors in Outline View
- Why is my Swift function not printing from inside the dataTask closure?
- Using UICollectionViewCell with IBOutlet
- Undefined symbol: _OBJC_CLASS_$_ only on simulator
- Why can't I receive a notification sent from Camera Extension(Swift) to an observer application (obj-c++)
- Behavior of __block modifier in objc
- Inserting subview into view where I've added subviews and sublayers
Related Questions in IOS
- URLSession requesting JSON array from server not working
- Incorrect display of LinearGradientBrush in IOS
- Module not found when building flutter app for IOS
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Occasional crash at NSURLSessionDataTask dataTaskWithRequest:completionHandler:
- Expo Deep linking on iOS is not working (because of Google sign-in?)
- On iOS, the keyboard does not offer a 6-character SMS code
- Hi, there is an error happened when I build my flutter app, after I'm installing firebase packages occurs that error
- The copy/paste functionalities don't work only on iOS in the Flutter app
- Hide LiveActivityIntent Button from Shortcuts App
- While Running Github Actions Pipeline: No Signing Certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID
- Actionable notification api call not working in background
- Accessibility : Full keyboard access with scroll view in swiftui
- There is a problem with the request entity - You are not allowed to create 'iOS' profile with App ID 'XXXX'
- I am getting "binding has not yet been initialized" error when trying to connect firebase with flutter
Related Questions in NSTIMER
- iOS Swift Timer sometimes fires much later than expected
- matplotlib animation vs python event loop (event loop gives choppy results)
- Timer not running when the app is in background
- Is there max limit that a timer can be set for?
- NSTimer interfering with user clicks
- How to setup long running timers on iOS
- Cannot convert value of type 'Timer' to expected argument type '(() -> Void)?' Swift 5
- Timer crashing screens in SwiftUI
- Xamarin NSTime RepeatingScheduledTimer is not getting called on Release Mode - Backgroud
- Invalidating a Timer created multiple times
- stop the timer which is executed after button click
- Making a spriteNode fade away
- How to run timer for two dates subtraction in Swift
- Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFTimer encodeWithCoder:]
- How to run a timer-based app at the same speed when the screensaver is active
Related Questions in UISLIDER
- Using values from sliderInput to reactively recalculate an equation and display the recalculated number as text
- Slider value is not updated
- How can I implement a custom Flutter slider that gradually increases it's track thickness?
- Increasing memory usage in iOS using a UISlider to update a UIImageView's image
- Slider in react js: How to set width to fill outer div correctly?
- RangeSlider inside of table fails to show value
- How to: Interact with a slider using Playwright
- Use Inputs from user as Min & Max values for UISlider
- Slider with process of loading track
- UISlider in Mac Catalyst updates UI too late
- Accessibility Voice over always announces initial value for adjustable trait changes
- How do I set initial music volume to be 50% using UIslider iOs? I am using AVFoundation
- uiSlider - Values and image of the slider are misaligned
- UISliders inside different UITableViewCells affect each other when continuous
- Why isn't the slider in my custom UITableViewCell reacting to the drag attempts?
Related Questions in NSTIMEINTERVAL
- How can I get non-overlapping sleep samples from HealthKit in Swift?
- How to convert a time pattern from a string to TimeInterval in Swift?
- Create table with 15 minutes interval on date time in Snowflake
- Problem Using a Switch to Set A TimeInterval
- How to modify formatted string with 'positional' option by using swift's DateComponentsFormatter
- Join and plot data with different times in 10 minute interval
- How can I handle this European-style timestamp?
- conversion from NSTimeInterval to days
- Random Element that is not repeating in every TimeIntervalNotification
- Random Element from Array with repeating TimeIntervalNotificationTrigger
- Call RESTful API while application in background state for indefinite time
- R: How to create a Date object using intervals?
- Having trouble trying to subtract a number from a date/time and setting that value in a textField
- Find difference between just the time of two dates in seconds
- How to subtract 30 minutes from a timeinterval in Swift?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
That's probably the best approach. The
NSTimershould behave fairly consistently at that interval, it only starts to get unreliable when calling it around every 1/10th second, or faster.However, a bit of explanation in case it doesn't quite behave as you'd hoped:
It won't be perfect because the
NSTimerdoesn't have it's tick event literally every interval. Rather, theNSTimeris at the mercy of it's thread's run-loop, which may not get around to calling your@selectormethod until a while after its interval has expired. Then combine that with calling for screen updates which are also not lock-step.It's accuracy will mostly depend on what else you're doing in your run-loop... if there's not much going on in your device's little brain, then your slider should appear to move just as you'd hoped.
Edit: You may also consider an NSTimer with a longer interval, and use the UIView's animateWithDuration... methods to make it appear smooth?