Search code examples
iosuitableviewcenteruiactivityindicatorview

How to put activityindicator middle of a tableview


I have put activity indicator

 spinner.center = CGPointMake( [UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
[self.view addSubview:spinner];

But this is not properly centered in the table view. Because table view can scroll. How can i put a spinner in the center of the screen.


Solution

  • try with bellow code:-

        spinner.center = CGPointMake( [UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
        yourAppdelegateClass *appDelegate = (yourAppdelegateClass*)[[UIApplication sharedApplication] delegate];
        [appDelegate.window addSubview:spinner];
    

    Code Output is:-

    enter image description here