UIActivityIndicatorView的startAnimating,stopAnimating开启或停止菊花转动画。
这个两个函数放在后台线程也是能操作的,动画效果也是能正常显示的。但是用Instruments检测,发现有内存泄露,泄露的地方 CA ::transaction::create
解决办法,在后台线程操作动画时,使用performSelectorOnMainThread同步到主线程。
示意代码
UIActivityIndicatorView *iv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
....
[iv performSelectorOnMainThread:@selector(startAnimating) withObject:nil waitUntilDone:YES];
....
[iv performSelectorOnMainThread:@selector(stopAnimating) withObject:nil waitUntilDone:YES];