I posted some code here that might help. But that code is mixed
with OP's code, so here's a clean version.
What you can do is subclass UIWindow and pass it to application delegate as its window.
Code would look something like:
MyKindOfWindow.h
#import <UIKit/UIKit.h>
@protocol MyKindOfWindowDelegate;
@interface MyKindOfWindow : UIWindow
@property (assign) id <MyKindOfWindowDelegate> touchDelegate;
@end
@protocol MyKindOfWindowDelegate <NSObject>
@required
- (void) windowTouch:(UIEvent *)event;
@end
MyKindOfWindow.m
#import "MyKindOfWindow.h"
@implementation MyKindOfWindow
@synthesize touchDelegate = _touchDelegate;
- (id)initWithFrame:(CGRect)aRect
{
if ((self = [super initWithFrame:aRect])) {
_touchDelegate = nil;
}
return self;
}
- (void)sendEvent:(UIEvent *)event
{
[super sendEvent: event];
if (event.type == UIEventTypeTouches)
[_touchDelegate windowTouch:event];
}
@end
Your AppDelegate
would of course need to follow MyKindOfWindowDelegate
protocol (implement - (void) windowTouch:(UIEvent *)event
method).
didFinishLaunchingWithOptions:
would look like:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[MyKindOfWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[(MyKindOfWindow *)self.window setTouchDelegate:self]; //!!make your AppDelegate a delegate of self.window
//this part of code might be different for your needs
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
} else {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}