tabview每个cell上放一个计时器
来源:互联网 发布:淘宝客流量稳定吗 编辑:程序博客网 时间:2024/05/16 17:15
后台获取的Model数据中时间秒数second存放在字典里,用indexPath做key值
-(UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
NSDictionary *dic = @{@"indexPath":[NSString stringWithFormat:@"%ld",indexPath.row],@"lastTime": model.second}; [_array addObject:dic]; NSLog(@"----%ld----",_array.count); //调用定时器 [self startTimer];
#pragma mark 定时器开启- (void)startTimer{ if (!self.timer) { self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(refreshLessTime) userInfo:nil repeats:YES]; //如果不添加下面这条语句,在UITableView拖动的时候,会阻塞定时器的调用 [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:UITrackingRunLoopMode]; }}
- (void)refreshLessTime{ NSUInteger time; for (int i = 0; i < _array.count; i++) { time = [[[_array objectAtIndex:i] objectForKey:@"lastTime"]integerValue]; NSLog(@"%ld",time); NSIndexPath *indexPath = [NSIndexPath indexPathForItem:[[[_array objectAtIndex:i] objectForKey:@"indexPath"] integerValue] inSection:0]; LXOrderingTableViewCell *cell = (LXOrderingTableViewCell *)[_tableView cellForRowAtIndexPath:indexPath]; cell.labPersistTime.text = [NSString stringWithFormat:@"%@",[self lessSecondToDay:++time]]; NSDictionary *dic = @{@"indexPath": [NSString stringWithFormat:@"%ld",indexPath.row],@"lastTime": [NSString stringWithFormat:@"%ld",time]}; [_array replaceObjectAtIndex:i withObject:dic]; }}- (NSString *)lessSecondToDay:(NSUInteger)seconds{ //秒化成 时分秒 显示 NSUInteger hour = (NSUInteger)(seconds/3600); NSUInteger min = (NSUInteger)(seconds%(3600))/60; NSUInteger second = (NSUInteger)(seconds%60); NSString *time = [NSString stringWithFormat:@"%lu小时%lu分钟%lu秒",(unsigned long)hour,(unsigned long)min,(unsigned long)second]; return time;}
阅读全文
0 0
- tabview每个cell上放一个计时器
- tabview cell
- tableviewcell 上放一个和cell 大小一样的button ,拦截了cell点击事件!!
- 自定义cell中放一个textField
- listview里面放chronometer计时器,如何设置只有一个计时器在工作
- tabview
- iOS每个Cell倒计时
- 一个计时器
- 一个计时器
- Listview每个item上加一个popupwindow
- 实现tabView 一个页面内有有多个子页
- 动手去实现一个页面切换TabView
- uitableview横放显示cell
- 计时器 每个一秒输出一次
- 获取一个数据每个位上的数据
- 关于tabview cell中的事件无法传递到next response 的问题(from stackoverflow)
- 设计一个计时器
- 一个计时器的实现
- iOS多线程全套:线程生命周期,多线程的四种解决方案,线程安全问题,GCD的使用,NSOperation的使用
- 重做日志文件(redo log file)
- SpringMVC---@ModelAttribute
- ajax请求
- 常用的DOS命令
- tabview每个cell上放一个计时器
- 进制的算法
- adb通过wifi来连接电视调试
- iOS崩溃 捕获异常处理
- ambari安装详解
- mysql慢查询日志开启与分析
- hadoop安全模式
- 指针直接赋值与strcpy区别
- c++友元函数声明及其调用