如何更新滚动视图中的标签文本ios
问题描述:
我在滚动视图iOS中有一个标签。
并更新标签文本的计时器。
它工作正常,但如果我滚动滚动视图,标签不更新如何更新滚动视图中的标签文本ios
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countDown) userInfo:nil repeats:YES];
- (void) countDown {
label.text = [[NSDate date] description];
}
答案在这里:My custom UI elements are not being updated while UIScrollView is scrolled
答
[self performSelector:@selector(onTick:) withObject:nil afterDelay:2.0];
-(void)onTick:(NSTimer *)timer {
label.text = //what you want.
}
希望这有助于..
+0
它可以当我滚动滚动视图时不更新标签文本 – mthuong 2013-03-27 17:38:53
答
使用此UIScrollViewDelegate方法更新标签
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
// here update your label
}
+0
我希望每隔一秒更新标签文本 – mthuong 2013-03-27 17:30:52
向我们显示代码。还请准确描述您的期望和看到/未看到的内容。 – rooftop 2013-03-07 17:39:08
http://stackoverflow.com/questions/4109898/my-custom-ui-elements-are-not-being-updated-while-uiscrollview-is-scrolled 这里是我的问题的答案 – mthuong 2013-03-28 01:42:07