B4i Library CADisplayLink - A Timer that ticks on each display refresh

Hi,

Please find attached a wrapper for iOS native CADisplayLink.

CADisplayLink is much better Timer for animations as it ticks on each display refresh rate.
(http://www.bigspaceship.com/ios-animation-intervals/)

I have added a function to add an Interval for each tick but if you don't need it just set Interval=0 and it will tick on each screen refresh rate.

see attached an example.

regards

Narek
 

Attachments

  • CADisplayLink.zip
    1.9 KB · Views: 74

tufanv

Expert
Licensed User
Longtime User
Hi,

Please find attached a wrapper for iOS native CADisplayLink.

CADisplayLink is much better Timer for animations as it ticks on each display refresh rate.
(http://www.bigspaceship.com/ios-animation-intervals/)

I have added a function to add an Interval for each tick but if you don't need it just set Interval=0 and it will tick on each screen refresh rate.

see attached an example.

regards

Narek
does making tmr.enabled=false also crashes at your example ? if i set to enable true there is no problem but if i set to false the app keeps on crashing on startup.
 

narek adonts

Well-Known Member
Licensed User
Longtime User

tufanv

Expert
Licensed User
Longtime User
Hi,

Please find attached a wrapper for iOS native CADisplayLink.

CADisplayLink is much better Timer for animations as it ticks on each display refresh rate.
(http://www.bigspaceship.com/ios-animation-intervals/)

I have added a function to add an Interval for each tick but if you don't need it just set Interval=0 and it will tick on each screen refresh rate.

see attached an example.

regards

Narek

the slide is very smooth now ! Thanks for your great module.
 

tufanv

Expert
Licensed User
Longtime User
Hi,

Please find attached a wrapper for iOS native CADisplayLink.

CADisplayLink is much better Timer for animations as it ticks on each display refresh rate.
(http://www.bigspaceship.com/ios-animation-intervals/)

I have added a function to add an Interval for each tick but if you don't need it just set Interval=0 and it will tick on each screen refresh rate.

see attached an example.

regards

Narek
Dear Narek,

I am successfuly using this in 2 of my apps. In a new app, I use the same codes but i am keep getting a log says : Subs not found: b4i_cadisplaylink
and i cant slide anything. Am i forgetting stg . You have an idea ?

edit: In realease mode , it works fine so i suppose it is a problem with a debug mode
 
Last edited:

Baris Karadeniz

Active Member
Licensed User
Hi,

Please find attached a wrapper for iOS native CADisplayLink.

CADisplayLink is much better Timer for animations as it ticks on each display refresh rate.
(http://www.bigspaceship.com/ios-animation-intervals/)

I have added a function to add an Interval for each tick but if you don't need it just set Interval=0 and it will tick on each screen refresh rate.

see attached an example.

regards

Narek

I used your codes in my app but ı get an error; Unknown type: cadisplaylink Are you missing a library reference?

What can be the problem?
 

tman

Member
Licensed User
Longtime User
I ran your example code ( Interval time set at 1000) and expected to get a 1 second timer. However the result was slightly shorter than 1 sec. I used it to increment a number counter (on a label) I was expecting it to count at once per second rate but it runs a little bit fast. I was wondering Why this value (1000) doesn't give me an accurate 1 second timer. I found that setting the interval value at 1017 (1.7% longer) works very well.
I also noticed that if the timer enabled = false and is set again to false your app will crash. Setting enabled to true more than once will not cause a crash.
 
Last edited:
Top