Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective C - UIActivityIndicatorView positioning

I have a UIActivityIndicatorView that I create and position in loadView function.

It works fine except that I can see for a split second the UIActivityIndicatorView on the top left corner before reposition itself to the center of the screen.

Why does it do that? And how can I prevent that?

I also try creating the UIActivityIndicatorView in viewDidLoad function and the same thing happens.

BTW, I'm using UIActivityIndicatorView as an example, but I also have a UIImageView that I alpha 0 and I also see it for a split second before it goes away.

Please enlight.

Thank you, Tee

like image 692
teepusink Avatar asked Feb 27 '23 23:02

teepusink


1 Answers

Try adding it to the view before you change its position:

[self.view addSubview:spinner];
spinner.center = self.view.center;
like image 143
PfhorSlayer Avatar answered Mar 06 '23 17:03

PfhorSlayer