I am trying to add a UIView
to UIWindow
using the appDelegate
I am using this code:
NSArray *myViewArray = [[NSBundle mainBundle] loadNibNamed:@"View" owner:self options:nil];
UIView *myView = myViewArray[0];
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
myView.frame = CGRectMake(0, 0, 258, 564);
[myView setTag:100];
[window addSubview:myView];
However this doesn't work. If I add it to my self.view
it works fine. However, I want this view to be onto of all other views when it appears.
What am I doing wrong here?
Edit
I used code from my last SO question: How to add a UIImage below UIBarButton item
There it worked fine, no problems.
However in this new project which only has a viewDidLoad method and one controller its not working.
Make sure you are adding the subview after you've initialised your window, set its rootViewController and called makeKeyAndVisible.