I wanted to add a view in UIWindow
with following code:
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
UIWindo
Try with this code:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window) {
window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}
UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
aView.backgroundColor = [UIColor redColor];
aView.center = window.center;
[window insertSubview:aView aboveSubview:self.view];
[window bringSubviewToFront:aView];
}
i think you are missing this. check once.
[self.window makeKeyAndVisible];