Giter Club home page Giter Club logo

mztimerlabel's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mztimerlabel's Issues

Time will not be set correctly if tableview reuse cells

The time of label is not correctly showed while tableview reuses cell. In my subclass cell, I set the MZTimerLabel in a timeStamp property setter method,

- (void)setTimeStamp:(NSUInteger)timeStamp
{
_timeStamp = timeStamp;

self.countLabel.timeFormat = @"mm:ss:SS";
if (_timeStamp > 3600) {
    self.countLabel.timeFormat = @"HH:mm:ss:SS";
}

if (_timeStamp && self.countLabel.counting) {
    [self.countLabel reset];
    [self.countLabel setCountDownTime:self.countLabel.getTimeRemaining];
} else {
    [self.countLabel setCountDownTime:_timeStamp];
}

WS(weakSelf);
[self.countLabel startWithEndingBlock:^(NSTimeInterval countTime) {
    NSLog(@"%zd",countTime);
    weakSelf.countLabel.text = @"Finished";
}];

}

It seems work, however, cell's self.countLabel.getTimeRemaining is not correctly.

if (_timeStamp && self.countLabel.counting) {
    [self.countLabel reset];
    [self.countLabel setCountDownTime:self.countLabel.getTimeRemaining];
} else {
    [self.countLabel setCountDownTime:_timeStamp];
}

The main logic is while counting is YES, assign the remaining time to the label instead of the original time data.

Timer stops too early

//Creating a timer
_timerView = [[MZTimerLabel alloc] initWithLabel:_timerLabel andTimerType:MZTimerLabelTypeTimer];
_timerView.timeFormat = @"HH:mm:ss,SS";
_timerView.countDownTime = _currentTimer.timeInterval; // timeInterval is for example 14
_timerView.delegate = self;
[_timerView start];

timerLabel:(MZTimerLabel *)timerLabel finshedCountDownTimerWithTime:(NSTimeInterval)countTime
is called when the label shows 00:00:00,99 so it doesn't count to zero.

Error counting

This project is great, but why the first second is not counted correctly (the initial value is not fully counted - it's not completely marks the first second) and why the end count 00:00:00 instead passing from 00:00:01 to the delegate? Call the delegate after 00:00:00 is to count a second more.
If you check clock app in iOS the countdown and generally every countdown works differently from MZT.
Is possible correct that?
Thanks

MZTimerLabel inside UITableViewCell?

Hi, I just found this project and I really like it. I have a timer in every UITableViewCell that I create and after a countdown of 24 hours, I want to delete the cell whose timer went to <= 0. Each timer will have a different time. I understand we can use the delegate method timerLabel(timerLabel: MZTimerLabel!, finshedCountDownTimerWithTime countTime: NSTimeInterval) to do things when the timer completes but is there a way to pass in the index of the UITableViewCell or the actual UITableViewCell to this delegate method so that I can delete the cell whenever that timer goes to 0? If you could help me, that would be great. Thanks!

Logic flaw

Hi,

There is a logic flaw:

if (self.timerType == MZTimerLabelTypeStopWatch && timeUserValue > 0) { startCountDate = [startCountDate dateByAddingTimeInterval:(timeUserValue<0)?0:-timeUserValue]; // no point at all to check for timeUserValue<0, because there is timeUserValue > 0 in outer IF }

timer in uinavigationbar

i'd like to insert label with timer in nav bar viz. in rightBarButtonItem. There is the code:

UILabel _label = [[UILabel alloc]initWithFrame:CGRectMake(0.0, 0.0, 40.0, 100.0)];
lblTimer = [[MZTimerLabel alloc] initWithLabel:label andTimerType:MZTimerLabelTypeTimer];
[lblTimer setCountDownTime:21_60];
lblTimer.bounds = CGRectOffset(label.bounds, 0, 0);
lblTimer.font = FONT_B(18.0f);
lblTimer.textColor = [UIColor whiteColor];
[lblTimer sizeToFit];
lblTimer.delegate = self;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:lblTimer];
[lblTimer start];

The result: in nav bar appears timer label with 00:00:00 (NOT 00:21:60) and timer is not starting... What am i do wrong? thanks for answering. With last holidays!=)

`timeFormat` 屬性的問題

如果我像這樣指定倒計時的格式:

timeLabel.timeFormat = @"MM-dd HH:mm:ss";

那麼將會得到一個錯誤的結果:MM 和 dd 表示的值會多 1。

比如最後 3s 的倒計時應該是 00-00 00:00:03,結果卻是 01-01 00:00:03

Feature request: blinking colon

Hi,

I am using a custom timeFormat (HH:mm).

So there is not much happening for at least 60 seconds. So I was thinking, it would be cool if the colon could be blinking every second. So that it feels more like a digital clock.

Is this something that would make sense incorporating?

Looking forward to your feedback.

Day counter problem for MZTimerLabelTypeTimer

Hello,

I want to use this wonderful timer to display seconds, minutes, hours and days remaining.
Unfortunately, the day value is incorrect (there is always an extra one day displayed).
Is there a workaround to get this working properly ?

Here is my code :
@IBOutlet weak var timer1: MZTimerLabel!
let interval = NSTimeInterval(8) // 8 seconds
timer1.setCountDownTime(interval)
timer1.timeFormat = "dd-HH-mm-ss"
timer1.start()
// displays 01-00-00-08 instead of 00-00-00-08

Thank you !

pausedTime force set to 'nil' after pause message being sent

For Countdown Timer logic in updateLabel method you have:

-(void)updateLabel{
// ...
[self pause];
timeToShow = [date1970 dateByAddingTimeInterval:0];
pausedTime = nil;
// ...
}

Pause method, however, does self.pausedTime = [NSDate date];
Is setting pausedTime to nil intentional?

How to stop the timer?

I set a timer label in one view, then back to the previous view using [self dismissViewControllerAnimated:YES completion:nil];. But the timer didn't stop because the delegate method was called when the timer was end.

MZTimerLabel, pause/start method not working properly

First of all thanks for this great pod/control

I have encountered an issue and would like to inform you. So I have MZTimerLabel in my view, actually it is a normal UILabel in storyboard file but in the code I used the initWithLabel: method to create a MZTimerLabel with an existing UILabel, everything works fine.

But then I wanted to include a pause screen in my viewController in my pauseTimer; function I called [timerLabel pause]; and did some other work. but when I resume the timer in another function of mine by calling [timerLabel start]; it would not resume from that time, rather it would resume from some random time which is 3-15 seconds added to the current time or just go to zero by its own.

I am waiting for your reply. Thanks

Adding a block for the timer independently of starting it

Hi and thanks for your great classes !

I was wondering : could you add a method to add a block to execute when a countDown timer ends independently of starting it ? I mean we could do

timerLabel.endingBlock = ^(NSTimeIntervall time){...} ;

Thanks

NSTimers not cleaned up on view destruction

Looking at the implementation of MZTimerLabel, it looks like the NSTimers are never invalidated when the MZTimerLabel instance is removed from the current view/window. For repeating timers, it's generally best practice to call invalidate when they are not being used anymore (e.g. the view is not shown) since they retain the target they are assigned to. This means that MZTimerLabel never has its dealloc method called.

From the [Apple docs]:

Once scheduled on a run loop, the timer fires at the specified interval until it is invalidated. A non-repeating timer invalidates itself immediately after it fires. However, for a repeating timer, you must invalidate the timer object yourself by calling its invalidate method. Calling this method requests the removal of the timer from the current run loop; as a result, you should always call the invalidate method from the same thread on which the timer was installed. Invalidating the timer immediately disables it so that it no longer affects the run loop. The run loop then removes the timer (and the strong reference it had to the timer), either just before the invalidate method returns or at some later point. Once invalidated, timer objects cannot be reused.

Looking at this [SO question], it looks like the best place to do this is in the removeFromSuperview method of the UIView.

iOS8 & Autolayout

As apple release iOS8 and the way to work with size classes, does anyone have issue on implementing MZTimerlabel using iOS8 + auto layout? If so, any suggestions?

HH:MM:SS Not showing as 12:MM:SS when countdown timer goes below 60 min.

Hi, I'm new to using MZTimerLabel, and it's an awesome little utility. I'm not sure if this is an isolated issue with XCode7 and iOS9 or not:

I'm using a countdown timer, with the following settings:

labelTimer = [[MZTimerLabel alloc] initWithLabel:lblLine8 andTimerType:MZTimerLabelTypeTimer];
[labelTimer setCountDownToDate:endDate];
labelTimer.timeFormat = @"hh:mm:ss";
labelTimer.resetTimerAfterFinish = NO;
labelTimer.delegate = self;
[labelTimer start];

Here's the issue:
When the endDate is over 1 hour ahead, then the labelTimer shows as e.g: 01:45:22, and can be seen counting down.

Then when the labelTimer drops from 01:00:00, it displays as 12:59:59 and shows counting down (but I would expect to see 00:59:59 and counting down).

If I manually set the countdown to less than one hour using: -(void)setCountDownTime:(NSTimeInterval)time, when the time format is: hh:mm:ss, then the label still shows as: 12:XX:XX

As a workaround, I've had to modify my code to check the value of the label timer using "- (NSTimeInterval)getTimeRemaining", and when it's > 1h, I set labelTimer.timeFormat = @"hh:mm:ss";
And when it's < 1h, I set labelTimer.timeFormat = @"mm:ss";

This sort of gets the job done, but it's not ideal.

Am I doing something wrong? I've checked over all the docs and the MZTimerLabel.h file to make sure I'm not missing anything. Maybe this is isolated to XCode7 / iOS9.

Thanks,

Chris

Call delegate method while app in background

I'm starting a countdown timer with a click on button in my app and set time to 10 seconds. After the countdown is finished, I start another countdown timer with 30 seconds. I use the delegate method -(void)timerLabel:(MZTimerLabel*)timerLabel finshedCountDownTimerWithTime:(NSTimeInterval)countTime to start second timer.
However, if I close the app immediatly after the first countdown timer started, the delegate method is never called and the second timer never starts. Only after I open the app.

Any idea how to start new timer while app is in background?

Use "resume" instead of "start"

Following Cocoa convention, I suggest changing [stopwatch start] to [stopwatch resume].

(and maybe add a pause feature as well).

Zombie, memory leaks

When you create instance of MZTimerLabel and it is not added as subview (You just create instance and then set timeLabel), removeFromSuperview is not fired > timer is not invalidated and instance stays in memory.

Didn't work inside TableView

Hello,

I try to add your label inside a tableView, but it doesn't work, it keeps showing in all cells and strange behavior.

关于时间设置颜色的问题

遇到一个需求,显示倒计时,用了你的,时间部分的设置需要不同颜色字体,但是没有提供相关接口

restore the UILabel text after count down finished

Hey there, great library! I want to request a feature that once the count down is finished, it will restore the label's text when it starts counting. Currently I can only use the delegate to restore the text.

Updated POD

Hi,

Could you please update POD with the latest fix?

Thanks,
H.

how to stop the timer?

Hello,
when I call reset method to stop the timer, it resets the timer value back to initial set value and restarts counting down.
How can I stop the timer and set the timer back to 0:00:00?
I am using Xcode 7 and ios9.
thanks!

New feature

A great new feature, but I think it might take time to implement, would be to be able to make several timers synchro: by this I mean that the seconds change at the same moment for all the specified timers.

Delegate Leak

Hi, delegate should properly follow the pattern and be a weak reference. That way you prevent any circular reference.

callback block is never called when userTime equals to 0

How to reproduce:

In example 7 edit the line

[timerExample7 setCountDownTime:0];

When starting the example, by tapping "Start", alert does not appear. (Hitting "Start" once again, though, shows the alert).

Reason:

When updateLabel is called for the first time by a timer object, the endedBlock is nil.

Possible fix:

Change the order of sending start and assigning the endedBlock block.

-(void)startWithEndingBlock:(void(^)(NSTimeInterval))end{
    self.endedBlock = end;
    [self start];
}
Note:

For this case, though, the delegate is called.

Hours showing 24+

First off, great pod! Works like a champ.

I have the countdown timer displaying days, hours, minutes, and secs. All of the time formats work except for the Hours, it displays over 24 hours. Do I need to set the max value for the Hours or is there something I might be missing?

screen shot 2015-03-04 at 10 42 44 am

MZTimerLabelTypeTimer countdown endBlock is called 1 second before actually.

Hi, great job!!

But, there is an issue, countdown time end block is not called properly, actually it is called 1 second before the finish time. Here is my code:

MZTimerLabel *countDownTimer = [[MZTimerLabel alloc] initWithLabel:secondsLabel andTimerType:MZTimerLabelTypeTimer];
[countDownTimer setCountDownTime:15];
countDownTimer.resetTimerAfterFinish = YES;
countDownTimer.timeFormat = @"mm:ss SS";
[countDownTimer startWithEndingBlock:^(NSTimeInterval countTime) {
      // Called when 14 seconds passed
}];

Countdown not working for more than 24 hours

Its not working in this scenario, please assist.

MZTimerLabel *timer = [[MZTimerLabel alloc] initWithLabel:someLabel andTimerType:MZTimerLabelTypeTimer];
[timer setShouldCountBeyondHHLimit:YES];
[timer setCountDownTime:3600 * 50];
[timer start];

Feature Request

It would be great if you allowed the timer to display more than 59 minutes if hours are not shown. Example 90:10. 90 minutes and 10 seconds.

MZTimerLabel in a multiview application

Hi!
Thanks for the pod!
I'm currently having issues in a multiview application. I've a stopwatch running in a view A but if I change to view B and I return to A the stopwatch is stop.
How can I fix this behaviour ?

Timer Counting Up

I create the timer and call...
self.countdown.setCountDownTime(60)
self.countdown.start()

but the timer label starts at 1 minute then starts to count up. Any help?

BOOL starting

This project is great! Congrats! Maybe a simple and helpful features is a BOOL to check the timer is been started but in that moment it is in pause maybe like this:
@Property (assign,readonly) BOOL starting;

Starts Ticking at 01:00

Hello,

First of all great little Library. I have got it all working however it always starts at 01:00.

The only thing I have done is set the time format to:

self.timerLabel.timeFormat = @"MM:ss";

Any clues?

2 Timer labels delay

Hi,

in my app I have 2 timer labels(countdown). I pause timers and resume few times. After 2 minutes it is delay first timer has about 1 second more. Where can be the problem?

Edit Timer

Hello,

What is the best way to edit the timer.

For example we have a timer running and then a user can tap and edit the current time displayed. I edit the label and start but it starts from the previous time.

I have tried "setStopWatch" but it only accepts NSTimeInterval, is their a quick way to edit the timer?

Countdown being reseted due long time in background

Hello there! How being doing?
Thanks for this awesome pod! :)

I'm currently having issues while running a countdown at background. If somehow the counter is more then 20 minutes or so, it resets when i get back to the app... How can i avoid this?

Best!
Rafa

Can use in collectioncell???

HI guys.

I encountered a problem when i use MZTimerLabel in collectioncell.

MZTimerLabel * test = [[MZTimerLabel alloc]initWithLabel:cell.timeLabel andTimerType:MZTimerLabelTypeTimer];

[test setCountDownTime:100];

[test start];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.