UIActivity 指示器在调用 NSObject 类的函数后不会停止
我有两个类:ClassA 和 ClassB`。
ClassA
实现UIViewController
。ClassB
实现NSObject
。
我在 A 类的方法中有 startAnimating UIActivityIndicator
,同时我需要调用 B 类的方法之一。执行 B 类的方法后,我将调用新的 A 类的方法,然后停止 UIActivityIndicator 动画
。这里一切都工作正常,除了 StopAnimating
。请帮助我找到解决方案。我不知道线程,如果我使用线程,它能解决我的问题吗?
I have two classes: ClassA
and ClassB`.
ClassA
implementsUIViewController
.ClassB
implementsNSObject
.
I have startAnimating UIActivityIndicator
in classA's method at the same time i need to call one of the Class B's Methods. After executing Class B's method, I'll call new classA's method and then Stop Animating UIActivityIndicator
. Here every thing is working fine, except StopAnimating
. Please help me to find the solution. I don't know about threads, if I use thread, will it solve my problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
线程似乎是解决这个问题的一种复杂方法。为什么不在 A 类中保留 UIActivity 指示器,并在 B 类 A 中调用的方法中停止动画。Woo 听起来很复杂。
没有理由不能将活动指示器指针传递给任何类。
如果这对你不起作用,我会查看通知,而不是沿着多线程路线走下去
threading seems like a complicated way to solve this. Why not retain a the UIActivity indicator in class A, and stop animating in the method you call in class A from B. Woo sounds complicated.
Theres not reason why you cant pass a pointer the activity indicator to any class.
If this doesn't work for you I'd look at notications rather than going down the multi-threaded route
要解决此问题,请使用以下代码
在.h文件中声明UIActivity指示器对象。
在要停止动画的地方调用以下方法。
To solve this problem, use the following code
Declare the UIActivity indicator object in the .h file.
Call the following method where you want to stopAnimating.