I have a subview added on app relaunch, on the applicationDidBecomeActive got called, but it’s not shown, what could be the reason?
- (UIView *)mySubView {
if (_mySubView == nil) {
_mySubView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_mySubView.opaque = NO;
_mySubView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f];
_mySubView.exclusiveTouch = YES;
[_mySubView setUserInteractionEnabled:NO];
}
return _mySubView;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
UIWindow *window = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
[window addSubview:[self mySubView]];
}
What’s more interesting is that – it’ll shown if I leave the app launched, turn off the device, then turn the device back on. But if I close the app, then relaunch it, I won’t be able to see the subview.
Please add the following line like this,
and also change the color
[UIColor blueColor];You will see the effect sure
Enjoy!