I am developing a simple browser project on mac, I did not use the default view manager.
Instead, I am writing the viewcontroller class BrowserViewController. and write in appdelegate
@interface AppDelegate()
@property (nonatomic, strong) BrowserViewController *browserController;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
self.browserController = [[BrowserViewController alloc] init];
[self.window makeKeyWindow];
[self.window setContentView:self.browserController.view];
}
@end
But when the application starts, it leads to the default view, and not to the BrowserViewController. I really don't know the reason.
Thanks for the help, I solved this problem. My solution is this:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
self.window = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO ];
self.browserController = [[BrowserViewController alloc] init];
self.window.contentViewController = self.browserController;
self.window.backgroundColor = [NSColor whiteColor];
[self.window makeKeyAndOrderFront:self];
}
source
share