- (UItableVIEwCell *) tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UItableVIEwCell *cell = [tableVIEw dequeueReusableCellWithIDentifIEr:@"txDevicesListCellID"]; if (cell == nil) { cell = [[UItableVIEwCell alloc] initWithStyle:UItableVIEwCellStyleSubTitle reuseIDentifIEr:@"txDevicesListCellID"]; } UIbutton *buttonutton = (UIbutton *)[cell vIEwWithTag:103]; UIActivityIndicatorVIEw *activityIndicator = (UIActivityIndicatorVIEw *) [cell vIEwWithTag:104]; button.tag = indexPath.row; return cell;}
和我的按钮的选择器方法是
-(IBAction)recevIErbuttonClick:(ID)sender{ UIbutton *button = (UIbutton *)sender; NSInteger index = button.tag; NSIndexPath* indexpath = [NSIndexPath indexPathForRow:serialNumber inSection:0]; UItableVIEwCell* cell = [self.mytableVIEw cellForRowAtIndexPath:indexpath]; activityIndicator = (UIActivityIndicatorVIEw*)[cell vIEwWithTag:index]; [activityIndicator startAnimating];}解决方法 我想我可以看出,纺纱商何时何地停止纺纱.
我将UIActivityIndicatorVIEw子类化到我自己的类中,重载了startAnimating和stopAnimating函数,并在其中插入了断点.我已经做了一个简单的单元格,只有一个微调器上我的课.我已经将微调框的动画属性设置为IB:
现在这里发生了什么.前两个屏幕截图有一个堆栈跟踪,指示两个动作(停止动画和启动它们)一个接一个地发生,在同一个专用函数_dIDMoveFromWindow:toWindow:
在我看来,这是在细胞创建流程中发生的,所以首先它没有动画初始化,然后IB设置启动并启动动画.现在这是有趣的部分,当微调停止动画:
所以看起来,当细胞从屏幕上移除时,微调器不断旋转,并且当单元格准备通过专用函数_removeAllAnimations再次显示在屏幕上(prepareForReuse)时停止旋转,该函数似乎递归地迭代所有子视图.
问题在于,由于某些原因,UIKit的私有功能不会重新启用动画,并且startAnimating永远不会被调用.实际上,IMO禁用动画是真正的问题.
我提出的解决方案,并不完美,但显然是苹果对我们的期望,是将UItableVIEwCell子类化为包含spinners的单元格,并在prepareForReuse中重新启用它们:
class SpinnerCell: UItableVIEwCell { @IBOutlet weak var spinner: UIActivityIndicatorVIEw? overrIDe func prepareForReuse() { super.prepareForReuse() if let spinner = self.spinner { spinner.startAnimating() } }}
或在Obj-C:
@interface SpinnerCell@property (weak) IBOutlet UIActivityIndicatorVIEw *spinner;@end@implementation SpinnerCell- (voID)prepareForReuse { [super prepareForReuse]; [self.spinner startAnimating];}@end总结
以上是内存溢出为你收集整理的ios – UIActivityIndicatorView停止在UITableViewCell中的动画全部内容,希望文章能够帮你解决ios – UIActivityIndicatorView停止在UITableViewCell中的动画所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)