[英]Calling function after thread/function completion
I would like to remove a view from another after the completion of a thread/another function in the class. 我想在该类中的线程/另一个函数完成后从另一个视图中删除一个视图。 At the moment I am using the following code to remove it after a set time period, but obviously, the function completion times varies
目前,我正在使用以下代码在设置的时间段后将其删除,但是显然,函数完成时间有所不同
LoadingView *loadingView =
[LoadingView loadingViewInView:self.view];
[loadingView
performSelector:@selector(removeView)
withObject:nil
afterDelay:10.0];
Is there a simple way of doing this? 有一个简单的方法吗? I've looked online and can't seem to find anything.
我在网上看过,似乎找不到任何东西。 Does this mean I have to write this functionality myself?
这是否意味着我必须自己编写此功能?
You can remove a view from the other thread with: 您可以使用以下方法从其他线程中删除视图:
[loadingView performSelectorOnMainThread:@selector(removeView) withObject:nil waitUntilDone:NO];
Of course you just need to maintain a reference to the loadingView somewhere that the thread can access. 当然,您只需要在线程可以访问的某个地方维护对loadingView的引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.