如何为 collection 视图创建 activity 指标。请参阅 post 中的详细信息

How to create activity indicator for collection view .see detail in post

我有一个 collection 视图。我尝试使用情节提要但无法添加。现在如何创建一个 uiactivity 指标 delay.and,它应该位于我的 collection 视图的中间中心,使用编程方式

任何人都可以帮助 me.I 我是 ios 的新手。我试过了,但没有动画 see.Please 帮助我。

  1. 当我的视图加载时,中间需要 activity 指示器
  2. 应该开始动画 2.0 秒,之后它应该 hide.Whenever 我的 collection 视图屏幕显示指示器应该开始动画 2.0 秒并且应该隐藏

我试过这个代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

   //self.navigationItem.hidesBackButton = YES;


    programaticActivityIndicatorView_ = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    [self.programaticActivityIndicatorView setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];
    [self.programaticActivityIndicatorView setHidesWhenStopped:YES];
    [self.programaticActivityIndicatorView setCenter:CGPointMake(150, 239)];


    [self performSelector:@selector(methodsq) withObject:nil afterDelay:3.0];

    [self.view addSubview:self.programaticActivityIndicatorView];



}

-(void)methodsq {

    [programaticActivityIndicatorView_ startAnimating];


}

但我一直在制作动画,但我只需要制作 3.0 秒的动画,之后它应该会隐藏 谢谢!

声明属性

@property (strong, nonatomic) UIActivityIndicatorView *indicator;

合成它

@synthesize indicator;

创建进程

CGRect rect = [[UIScreen mainScreen] bounds];
self.indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
self.indicator.frame = CGRectMake((rect.size.width-50)/2, (rect.size.height-50)/2, 50, 50);
self.indicator.hidesWhenStopped = YES;
[self.view addSubview:self.indicator];

开始进程

[self.indicator performSelector:@selector(startAnimating) withObject:nil afterDelay:0.1];

想隐藏就隐藏

[self.indicator performSelector:@selector(stopAnimating) withObject:nil afterDelay:2.0];