Я просто пытаюсь создать подкласс 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;
}