I am recreating some kind of UIAlertView to my application, so I will subclass UIWindow to do this. The window is added to [UIApplication sharedApplication].windows , but it never actually displays. I trimmed it to this small piece of code:
UIWindow *testWindow = [[UIWindow alloc] initWithFrame:self.view.bounds]; testWindow.backgroundColor = [UIColor blueColor]; [testWindow makeKeyAndVisible];
When I write [UIApplication sharedApplication].windows , I see:
"<UIWindow: 0x83774f0; frame = (0 0; 320 480); opaque = NO; autoresize = RM+BM; layer = <UIWindowLayer: 0x8377660>>", "<UIWindow: 0x8382630; frame = (0 0; 300 400); layer = <UIWindowLayer: 0xf573e60>>"
And yet, the second window with a blue background is now not visible.
UPDATE : this seems to be a problem only with ARC enabled. I created 2 new projects of a “single view”, one with ARC turned on and the other with ARC turned off. Both are identical, and I add the UIWindow code to viewDidAppear: main view controller. When I launch applications in the simulator, a blue window appears only in the project with ARC disabled. It seems like ARC is getting rid of my UIWindow too quickly, so it doesn't even have time to appear. __strong did not help to do this. Still clueless ...
source share