UIActivityIndicatorView

UIActivityIndicatorView

本文介绍了UIActivityIndi​​catorView正确用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是关于在iPhone项目中使用活动指示器的问题.我有一个包含UIActivityIndi​​catorView

My question regards the use of activity indicator in an iPhone project.I have a class that contains an UIActivityIndicatorView

@interface StatusView : UIView
{
    UIActivityIndicatorView *indicator;
    UILabel *textLabel;

}

- (id)initWithFrame:(CGRect)frame Text:(NSString*)text andShowIndicator:(BOOL)value;

在我的业务逻辑代码中,我调用[indicator startAnimating],并且该框架出现在屏幕底部.该代码还包含一个释放指标的dealloc方法

In my business logic code I call [indicator startAnimating] and the frame appears at the bottom of the screen. The code also contains a dealloc method that releases the indicator

- (void)dealloc
{
    [indicator release];

    [super dealloc];
}

大多数情况下,指标运行良好,但是在某些情况下永远不会消失.

Most of the time the indicator works well, however there are a few occasions that never disappears.

我是否总是需要显式调用stopAnimating方法?发行版可以处理吗?正确的用法是什么?

Do I always need to explicitly call the stopAnimating method? Does the release handle it?What is the proper usage?

推荐答案

stopAnimating:方法停止 UIActivityIndi​​catorView release 的释放object.
在Objective-C中,每个对象都有一个内部计数器,该计数器用于跟踪对象或对象使用的所有引用. [对象保留] 将计数器加1,而 [object release] 将计数器减1.当计数器达到零时,将调用dealloc. release 是关于内存管理的,而 stopAnimating: UIActivityIndi​​catorView 的功能.因此,如果您想停止对 UIActivityIndi​​catorView 进行动画处理,则必须调用 stopAnimating:方法.在 ARC 中,不必执行 release ,因此最好使用 ARC .

stopAnimating: method stops the wheel of UIActivityIndicatorView and release release the object.
In Objective-C each object has an internal counter that is used to keep track of all references used by the objects or object has. [object retain] increments the counter by 1 and [object release] decrements the counter by 1. When counter reaches to zero, dealloc is then called. release is about memory management while stopAnimating: is a functionality of UIActivityIndicatorView.So if you want to stop animating your UIActivityIndicatorView you would have to call stopAnimating: method. In ARC dont have to do release so better to use ARC.

这篇关于UIActivityIndi​​catorView正确用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 10:04