Создание подкласса UIWindow

Я просто пытаюсь создать подкласс UIWindow, чтобы я мог перехватывать некоторые уведомления. Наряду с приведенным ниже кодом я также захожу в MainWindow.xib и обновляю объект UIWindow до моего подкласса. Он загружается нормально, проблема в том, что вкладки на моей панели вкладок не отвечают (в приведенном ниже примере я добавил только одну вкладку, но в моем приложении их несколько (это не проблема)). Может ли кто-нибудь увидеть, что я делаю не так? Спасибо.

UISubclassedWindow.h

#import <UIKit/UIKit.h>

@interface UISubclassedWindow : UIWindow 
{

}

@end

UISubclassedWindow.m

    #import "UISubclassedWindow.h"

    @implementation UISubclassedWindow

- (id) initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) 
    {
        NSLog(@"init");
    }
    return self;
}

    - (void)makeKeyAndVisible
    {
        [super makeKeyAndVisible];
        NSLog(@"makeKeyAndVisible");
    }

    - (void)becomeKeyWindow
    {
        [super becomeKeyWindow];
        NSLog(@"becomeKeyWindow");

    }

    - (void)makeKeyWindow
    {
        [super makeKeyWindow];
        NSLog(@"makekeyWindow");
    }

    - (void)sendEvent:(UIEvent *)event
    {
    }

    - (void)dealloc 
    {
        [super dealloc];
    }

    @end

AppDelegate.h

import

@class UISubclassedWindow;

@interface My_AppAppDelegate : NSObject <UIApplicationDelegate> 
{
    UISubclassedWindow *window;
}

@property (nonatomic, retain) IBOutlet UISubclassedWindow *window;

@end

AppDelegate.m

@synthesize window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{   
    UITabBarController *tabBarController = [[UITabBarController alloc] init];

    MainViewController *mainViewController = [[MainViewController alloc] initWithViewType: 0];
    UINavigationController *mainNavigationController = [[UINavigationController alloc] initWithRootViewController: mainViewController];
    mainNavigationController.title = @"Main";
    [[mainNavigationController navigationBar] setBarStyle: UIBarStyleBlack];

    [tabBarController setViewControllers: [NSArray arrayWithObjects: mainNavigationController,  nil]];

    [self.window setRootViewController: tabBarController];
    [self.window makeKeyAndVisible];

    [mainViewController release];
    [mainNavigationController release];
    [tabBarController release];

    return YES;
}
5
задан Ser Pounce 24 January 2012 в 05:17
поделиться