Animating Activity Indicator on iOS launch screen
Solution 1
What you are trying to achieve is to show ActivityIndicator during launch screen which is not possible, but you can achieve it by some different way.
Here is the idea that may help you:
- Create separate loading page & call it from didFinishLaunchingWithOptions method in App delegate
- Add Splash image & indicator to it
- You can set timer of 2-3 seconds than redirect to your first page of app
While using indicator make sure you have checked StartAnimating to true or simply add indicator programmatically like this:
UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(225, 115, 30, 30)]; [activity setBackgroundColor:[UIColor clearColor]]; [activity setActivityIndicatorViewStyle: UIActivityIndicatorViewStyleGray]; [self.view addSubview: activity]; [activity startAnimating];
Hope it will work for you.
Solution 2
You can't use animations on the Launch Screen.
If you want to do any animations on the "launch screen", instead use your first view controller as a splash view.
Zoeb S
I am a developer who is passionate about programming in general and iOS development in particular and looking for a position that offers challenging work and both personal and professional growth. My true strength and passion lies in the design and development of iOS applications using Swift/Objective-C. I'm strong with overall application architecture design and an expert at finding and fixing crashing bugs. I have a clear understanding of memory management, multithreading via dispatch queues, and iPhone core services including Text & Email, Camera & Photos, Contacts, etc. I strictly follow Cocoa coding conventions and best practices with strong focus on writing readable and maintainable code using clear and explicit variable and method names.
Updated on June 20, 2022Comments
-
Zoeb S about 2 years
Is it possible to use
UIActivityIndicator
on the iOS launch screen?I tried, but it's not animating.
Has anyone tried this or know whether it's possible?
-
Debanjan Chakraborty over 9 yearsThat's what I would do
-
OhadM almost 9 yearsPay attention that the launch image is on full screen and if you use for example navigation controller, you might have issues with it.
-
Fawkes over 8 yearsYou did not check this solution. And it is not working also technically speaking, because as stated above at the launchscreen your app is not yet running, so Launch Screen is more of a static image the system puts while preparing your app to run.
-
StaRbUck42 almost 7 yearsI like doing this method, especially when the initial screen changes from launch to launch