IPhone center activity indicator regardless of screen orientation

How can I centralize the activity indicator programmatically, regardless of screen orientation?

+7
source share
2 answers

Try setting the center property of your activity type, for example:

  activity.center = CGPointMake(self.view.frame.size.width/2,self.view.frame.size.height/2); 

viewDidLoad in viewDidLoad for device rotation notifications:

 - (void)viewDidLoad { [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; } 

and implement didRotate:

 -(void)didRotate:(NSNotification *)notification { if (activity) { activity.center = CGPointMake(self.view.frame.size.width/2,self.view.frame.size.height/2); } } 
+12
source

I suggest you use https://github.com/jdg/MBProgressHUD This is a great library for doing all kinds of Download screens.

+1
source

All Articles