IOS 设置定时器

IOS 设置定时器  自动滚动视图 定时发送坐标信息 即时显示 时钟

复制代码
NSTimer *timer;
- (void)start
{//1second 调用一次
    timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateClock:) userInfo:nil repeats:YES];
}
-(NSString *)updateClock:(NSTimer *)theTimer //精确到分系统时间
{
    NSDate * senddate=[NSDate date];
    
    NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
    
    //  [dateformatter setDateFormat:@"ss:SS"];//hh:mm:ss:SSS
    [dateformatter setDateFormat:@"hh:mm"];
    NSString * locationString=[dateformatter stringFromDate:senddate];
   // NSLog(@"==%@==",locationString);
    label_System_hour.text=locationString;
    return locationString;
}

- (void)stop
{
    [timer invalidate];
    timer = nil;
}
复制代码

 

posted on   ACM_Someone like you  阅读(295)  评论(0编辑  收藏  举报

编辑推荐:
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
阅读排行:
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示