单击表格单元格时如何为视图设置活动指示器 [英] How to set activity indicator for a view when Click the table cell

查看:84
本文介绍了单击表格单元格时如何为视图设置活动指示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用故事板开发一个iPad应用程序。在我的视图控制器中,一个表设置为左侧,另一个视图设置为右侧。我需要在右侧视图上方设置一个活动控制器。当我单击右侧表格单元格并需要在1秒后停止时需要开始制作动画。我正在使用'didSelectRowAtIndexPath'功能选择表格单元格。如何为我的情况设置活动指示器。

I am developing one iPad application using story board.In my view controller one table is set as the left side and one more view is set as the right side.I need to set one activity controller above the right side view.Which need to start animating when i click the right side table cell and need to stop after 1s.I am using 'didSelectRowAtIndexPath' function for select table cell.How i will set activity indicator for my situation.

推荐答案

在didSelectRowAtIndexPath方法中,您可以调用以下函数: -

In didSelectRowAtIndexPath method you could make a call to below function:-

-(void)setActivityIndcator:(UIView *)view
{
  transparentView = [[UIView alloc] init];
  transparentView.frame = view.frame;  //Provide frame of right side view.
  transparentView.alpha = 0.5;   //To provide transparent look and feel.

  activityInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

  activityInd.frame = CGRectMake(transparentView.frame.size.width/2, transparentView.frame.size.height/2, 50, 50);  //Change as you want it to be

  [transparentView addSubview:activityInd];

  [activityInd startAnimating];

  [self performSelector:@selector(stopIndicator) withObject:self afterDelay:1];
}

-(void)stopIndicator  //This method will be called after delay and would remove view and activityInd
{
  [activityInd stopAnimating];

  [activityInd removeFromSuperview];
  [transparentView removeFromSuperview];
}

您还可以创建它的子类并通过创建在任何viewcontroller中使用它它的目标。这就是为什么你不需要每次写下所有函数。

Also you could create a subclass of it and use it in any viewcontroller by creating it's object. That why u don't need to write down all function everytime.

这篇关于单击表格单元格时如何为视图设置活动指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆