- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用的是Xcode 5.1,并且具有一个倒计时计时器,该计时器不会在00:00:00:00停止计时,并且会一直递减为负数,请您帮助以下代码显示:
请注意,datelabel.text是计时器的显示位置。
-(void)updatelabel{
NSCalendar *calender= [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
int units = NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents *components = [calender components:units fromDate:[NSDate date] toDate:destinationdate options:1];
[datelabel setText:[NSString stringWithFormat:@"%d%c %d%c %d%c %d%c %d%c", [components month], 'm',[components day], 'd',[components hour], 'h',[components minute], 'm',[components second], 's']];
}
if ([store.offer isEqual:@"No"] || [store.offerexp isEqual:@"3600"] ) {
datelabel.text =@"xx";
} else {
destinationdate = [NSDate dateWithTimeIntervalSince1970:store.offerexp.intValue];
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updatelabel) userInfo:nil repeats:YES];
NSLog(@"destination%@",destinationdate);
}
NSTimeInterval TimeStamp = [[NSDate date] timeIntervalSince1970];
最佳答案
到达destinationdate
后停止计时器。
- (void)updateLabel:(NSTimer *)timer {
NSDate *now = [NSDate date];
if ([now compare:destinationdate] != NSOrderedAscending) {
NSCalendar *calender= [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
int units = NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents *components = [calender components:units fromDate:now toDate:destinationdate options:1];
[datelabel setText:[NSString stringWithFormat:@"%dm %dd %dh %dm %ds", [components month], [components day], [components hour], [components minute], [components second]]];
} else {
[timer invalidate];
dateLabel.text = @"0m 0d 0h 0m 0s";
}
}
@selector(updateLabel:)
而不是
@selector(updatelabel)
。
if
。它可能需要是
NSOrderedDescending
。
关于ios - 倒数计时器不会在00:00:00:00:00停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25220797/
如果我有一个变量 8589934592 示例: var a = (8589934592 | 0); //a is 0 var b = (8589934591223 | 0); //b
随着我们提高音阶,音符频率增加; #define A4 440 // These are the frequencies of the notes in herts #define A
我有一个这样组织的列表: [('down', 0.0098000000000000309), ('up', 0.0015000000000000568), ('down', 0.00890000000
如果我有一个多项式 P,有没有办法计算 P^-1 模 Q,即 Q 是另一个多项式?我知道这两个多项式的系数都属于以 z 为模的整数域,即 z 是一个整数。 我不确定 SymPy 是否已经在其 galo
对于给定的文件,我可以向后计算行数吗?即从 EOF 开始,计算行数直到开始? 我可以 fseek 到文件末尾。从那里开始,继续寻找新行字符(新行的指示)并继续增加我的 line_number 计数。但
有什么方法可以编写带除法的 C 代码来命令编译器在代码中需要常规除法精度的几个特定位置不使用快速除法(通过倒数数学),即使在全局允许倒数数学的情况下也是如此? 理想情况下,有一种方法不是特定于编译器的
我正在尝试将照片从我计算机上的本地文件导入到我的 HTML 文件中。我已经设法做到了,但它是按升序排列的。我尝试添加一个变量 JavaScript $(document).ready( functio
我正在尝试使用 commons-math 计算 2 尾学生分布的逆。我正在使用 Excel 来比较值并验证结果是否正确。 所以使用excel计算TINV,自由度为5,我使用95.45% =TINV(0
我有一个 jQuery 相机插件,它使用以下命令来拍摄快照。 这是它运行的代码。 function take_snapshot() { // take snapshot and get i
我刚刚学会了训练 brain.js network 并且只是在玩它。然后我很好奇是否可以采取相反的方式 - 从输出预测输入? 这是我的代码 const brain = require('brain.j
如果精度不重要,有什么方法可以提高速度的倒数(X 的除法 1)? 所以,我需要计算 1/X。是否有一些解决方法让我失去精度但做得更快? 最佳答案 𝗛𝗲𝗿𝗲𝗛𝗲𝗿𝗲𝗛𝗼𝘄𝗧𝗼?
令 N 为整数。如果N = 2536,则反转N为6352。如果N = 1000000,则反转N为1。 给定一个整数 M,其中 1 <= M <= 10^(100000)。 我们需要找到一个整数 N 是
我是一名优秀的程序员,十分优秀!