A window will appear that is automatically created by the program, but does not respond to touch events.

I create my application without MainWindow nib, and after upgrading to the new SDK, my application completely broke. In main () of the main.m function, I have:

int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate"); 

Here are the relevant application bits: didFinishLaunchingWithOptions: in AppDelegate.m

 window = [[UIWindow alloc] init]; tabBarController = [[UITabBarController alloc] init]; UINavigationController *nav = ...; UITableViewController *table = ...; tabBarController.viewControllers = [NSArray arrayWithObjects:nav, table, nil]; [window addSubview:tabBarController.view]; [window makeKeyAndVisible]; 

When the application starts, the tab bar is visible, and it is also the view on the first tab. However, all touch events are either not recorded or are not transmitted to the window itself. I subclassed UIWindow and set window as an instance of this. In this subclass, I overloaded the sendEvent: method to enter the console with every call. I can not see anything. What am I doing wrong?

+4
source share
5 answers

Well, I figured it out. Hope this helps someone. These are the first lines in my application: didFinishLaunchingWithOptions: method:

 window = [[UIWindow alloc] init]; window.screen = [UIScreen mainScreen]; // this fixes the problem 
+4
source

You can try changing the fourth parameter from "nil" to the name of the application delegate in main.c

For example Change UIApplicationMain (argc, argv, nil, nil) to UIApplicationMain (argc, argv, nil, @ "HelloWorldAppDelegate")

+2
source

I had a similar problem and it helped me add

 [window setRootViewController:tabBarController]; 

... I just added a view instead of the entire view controller.

0
source

I had a similar problem when deleting mainwindow.xib and programmatically creating a window: I still had this line:

[self.window addSubview: rootcontroller.view];

Removing this solution to the problem.

0
source

For me, I had to use:

 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

Instead

 self.window = [[UIWindow alloc] init]; 
0
source

All Articles