从主线程外部重绘 IOS 中的视图
我有一个 (void) buttonClicked: (id) sender{} 方法。用户单击按钮后,对 gui 进行了两次更改,按以下顺序:
- 更改 A
- 使用 [NSThread sleepFortimeInterval: 5] 等待五秒
- 更改 B
不幸的是,从 buttonClicked 方法内部,我似乎无法获取视图在更改 A 后刷新,以便在退出 buttonClicked 方法时只有更改 B 可见。我知道视图只能在主线程内更改,并且我已经看到对 PerformSelectorOnMainThread 方法的引用,但我不知道如何调用它,以及如何使用它刷新视图。
I have a (void) buttonClicked: (id) sender{} method. After the user clicks the button, two changes to the gui are made, in this order:
- Change A
- Five second wait using [NSThread sleepFortimeInterval: 5]
- Change B
Unfortunately, from inside the buttonClicked method, I can't seem to get the view refreshed after Change A, so that only Change B is visible upon exiting from the buttonClicked method. I understand views can only be changed from within the main thread, and I've seen references to the performSelectorOnMainThread method, but I can't figure how to call it, and how to refresh the view using it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论