How to set activity indicator for a view when Click the table cell

前端 未结 3 617
醉酒成梦
醉酒成梦 2021-01-29 12:00

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 activ

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-29 12:45

    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];
    }
    

    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.

提交回复
热议问题