Big*_*Lex 8 iphone xcode objective-c ios
我是初学者,我正在尝试编写和应用iOS,它将在主屏幕上向用户显示一个从25分钟到0的定时器(由UILabel每隔一秒更新一个文本组成NSTimer)和一个UITableView(嵌入式)在UIViewController主屏幕中),每次定时器到达0时将显示一个单元格.
所以在我控制的主视图中UIViewController我有: - UILabel:对于定时器 - UITableView:每次定时器达到0时显示一个单元格 - UIButton:启动定时器
一切似乎工作得很好,除了滚动UITableView意志停止计时器更新标签,只要用户将手指放在tablewView上.谁能告诉我为什么标签UITableView在滚动时不会改变文字?
PS我认为这个问题可能与我没有使用线程的事实有关,因为我还没有学会使用它们.
Swift 3.x中的解决方案:
self.updateTimer = Timer.scheduledTimer(timeInterval:1.0, target: self, selector: "updateFunction", userInfo: nil, repeats: true)
RunLoop.current.add(self.updateTimer, forMode: RunLoopMode.commonModes)
Run Code Online (Sandbox Code Playgroud)
updateTimer = [NSTimer scheduledTimerWithTimeInterval:.01 target:self selector:@selector(updateCurrentTime) userInfo:p repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:updateTimer forMode:NSRunLoopCommonModes];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4070 次 |
| 最近记录: |