When I execute the code below in the simulator, I expect to see a red fill of the screen, but instead everything is black, why?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIView * myView = [[UIView alloc] initWithFrame:[window bounds]]; [myView setBackgroundColor:[UIColor redColor]]; [window addSubview:myView]; [window makeKeyAndVisible]; return YES; }
Adding window initialization will not help:
window = [[[UIWindow alloc] init] initWithFrame:[[UIScreen mainScreen] bounds]];
My problems started when, after creating a universal window-based project in Xcode, I decided to delete the xib files for iPad / iPhone and the iPhone / iPad delegate files that were automatically created in the project, and instead there is one application delegate with a view controller that creates device-based software presentation. Now I can not show the simple view that I create in the applicationβs delta.
Edit: I removed the view add and now set the window's background color to red. This does not help, but if I go to the desktop in the simulator and run the application again, now I will have a red screen. Again, I am puzzled by why I do not see red when I first start the application.
source share