MRB
MRB

Reputation: 43

iOS: How to have a small view visible in many views without initializing it in every view?

Just as the title states, I am looking to have a small notification view that will be present in all views of the application. Is there a way to do this without initializing it in every single view?

Upvotes: 2

Views: 249

Answers (2)

aroth
aroth

Reputation: 54846

@interface SharedViewManager {
}

+ (UIView*) getSharedView;
@end



@implementation SharedViewManager 

static UIView* sharedView = nil;

+ (UIView*) getSharedView {
    if (sharedView == nil) {
        //initialize the view
    }
    return sharedView;
}

@end

Upvotes: 1

Deepak Danduprolu
Deepak Danduprolu

Reputation: 44633

Attach it to the UIWindow object. This way it will be available on every view.

Upvotes: 3

Related Questions