I'm trying to add my custom activity indicator to my app.
Since there are many places I want to show the indicator,
I thought maybe it's a good idea to make it singleton to access it easily.
I guess I can slightly modify this to make the desired singleton class. Singleton Class iPhone
One problem is that I need to add the indicator view to some view(as subview) obviously.
And wonder if there is a singleton -like view that I can access from anywhere to add the indicator view as subview.
Thank you
you can use singleton, but I would advise you not to use singleton for UIView elements.
UIView elements can only have one superview, so if you use singleton.activityindicator everywhere, you will have to remove it from superview before adding it to new view, so alot of bookkeeping is required. For example, you have to remove it from prev superview when showing it else where, and when you come back to prev superview (through user clicking on some nav control or something), you have to determine if you need to now add it back to the new superview, etc.
I do use singleton for one UIView in my design, that is Ad banner view. I wanted to keep one ad across the app, to have same ad in different nav controllers. However it was big pain in the butt.
Just create one, add to the view, and remove when done.. simpler in my opinion :)