UIView 不更新 UILabel
在我的应用程序中,从另一个类调用委托回调函数。这个委托函数是重画屏幕。 就像,
-(void)repaint {
[self.view setNeedsDisplay];
}
我什至从 UIView 中删除了子视图,然后再次添加了子视图。但问题仍然存在。
我的 UIView 没有更新。
我有 NSLog label.text 并且文本已更新。但屏幕视图没有更新。
任何人都可以帮助我吗?
谢谢
In my application, a delegate callback function is called from another class. This delegate function is to repaint the screen.
like,
-(void)repaint {
[self.view setNeedsDisplay];
}
I have even removed the subview from UIView and then added the subView again. But still the problem persists.
My UIView is not updating.
I have NSLog the label.text and the text is updated. but screen view is not updating.
Can anyone please help me.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个想法和一个建议。如果你正确地更改了文本,那么你不需要告诉你的视图 setNeedsDisplay - 标签会告诉它。 (当您在drawRect:中有需要执行的代码时,通常会完成该调用。)
1)当标签更改时,是在主线程上完成的吗?回调是在主线程吗?在代码中检查标签的任何位置添加断言:
2)在上面的委托中,尝试更改与该标签相关的一系列内容
An idea and a suggestion. If you properly change the text then you do not need to tell your view setNeedsDisplay - the label will have told it to. (That call is normally done when you have code in drawRect: that you need executed.)
1) When the label is changed, is it done on the main thread? Is the callback on the main thread? Add an assert to your code anywhere that label is checked:
2) In the delegate above, try changing a bunch of things relating to that label