C#制作秒表下载

iOS开发练习小程序——秒表 - 博客频道 - CSDN.NET
念茜的博客
我是一单线程妞儿
分类:【iOS 应用程序开发】
& & & &最近工作不忙,闲暇之余自学了一下object-c,体验了一把ios无敌的framework。想写个小应用练练手,给自己挑了个简单的题目:模仿实现一下ios系统应用时钟里的秒表程序,就是这个应用:主要实现的功能:1.由start/stop键实现计时2.有reset/lap键实现复位和计次需要思考的点:1.时间的表示方法(有很多种思路)2.计次数据的倒序排列,即计次1的数据在最底端,依次向上为计次2,计次3的时间数据我的实现:ARC省去了我们自行管理内存的大部分事情,写惯了c++于是舒服了很多- (IBAction) startOrstop:(UIButton *)sender
//点击切换按钮背景图
UIImage *newImage = (checked) ? [UIImage imageNamed:@&red.png&] : [UIImage imageNamed:@&green.png&];
[leftBtn setBackgroundImage:newImage forState:UIControlStateNormal];
NSString *titlel = (checked) ? (@&Stop&) : (@&Start&);
[leftBtn setTitle:titlel forState:UIControlStateNormal];
NSString *titler = (checked) ? (@&Lap&) : (@&Reset&);
[rightBtn setTitle:titler forState:UIControlStateNormal];
if (checked)
timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updateTime) userInfo:nil repeats:YES];
[timer invalidate];
checked = !
- (IBAction) resetOrLap:(UIButton *)sender
static NSInteger count = 1;
if (checked) //reset
time = time_lap = 0.0;
timestr = [NSString stringWithFormat:@&00:00.0&];
[label setText:timestr];
list_time = list_lap =
count = 1;
[tableview reloadData];
if (list_time == nil) {
list_time = [[NSArray alloc]initWithObjects:timestr_lap, nil];
list_lap = [[NSArray alloc]initWithObjects:[NSString stringWithFormat:@&%d&,count++], nil];
[list arrayByAddingObject:timestr];
NSArray *array = [[NSArray alloc]initWithObjects:timestr_lap, nil];
list_time = [array arrayByAddingObjectsFromArray:list_time];
array = [[NSArray alloc]initWithObjects:[NSString stringWithFormat:@&%d&,count++], nil];
list_lap = [array arrayByAddingObjectsFromArray:list_lap];
time_lap = 0;
[tableview reloadData];
- (float) updateTime
time+=0.1;
time_lap +=0.1;
timestr = [NSString stringWithFormat:@&%02d:%04.1f&,(int)(time / 60) ,time - ( 60 * (int)( time / 60 ) )];
timestr_lap = [NSString stringWithFormat:@&%02d:%04.1f&,(int)(time_lap / 60) ,time_lap - ( 60 * (int)( time_lap / 60 ) )];
[label setText:timestr];
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
return [list_time count];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *tableViewIdentifier = @&tableViewIdentifier&;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:tableViewIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:tableViewIdentifier];
NSUInteger row = [indexPath row];
cell.detailTextLabel.text = [list_time objectAtIndex:row];
cell.detailTextLabel.textColor = [UIColor blackColor];
cell.detailTextLabel.font = [UIFont boldSystemFontOfSize:25.0];
cell.detailTextLabel.textAlignment = UITextAlignmentC
NSString *text = [[NSString alloc]initWithFormat:@&lap %@&, [list_lap objectAtIndex:row]];
cell.textLabel.text =
效果图:&待改进的地方:1.对于时间的计时操作和UI事件应该分不同线程实现,这里我偷懒了2.对于时间的表示方法其实也是很偷懒的,没有按照标准的秒分进位表示如有发现任何错误、不妥的地方请指点,谢谢。
yiyaaixuexi
排名:第168名
本博客中所有原创文章及译文均采用进行许可
(3)(9)(26)(71)(3)(26)(2)(6)关于在线秒表
模拟秒表、计时器的原理,方便您计算时间。
随机推荐查询工具
CopyRight &
All Rights ReservedC#大作业计算机和秒表的设计_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
C#大作业计算机和秒表的设计
上传于||暂无简介
阅读已结束,如果下载本文需要使用1下载券
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩7页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢Copyright(C) 2Soft-寒夜听雨 版权所有

我要回帖

更多关于 c7 秒表 的文章

 

随机推荐