调整窗口大小时应用会冻结吗?

时间:2015-06-17 11:17:20

标签: macos cocoa nswindow

我正在处理菜单栏应用程序并且我已经制作了一个自定义(无边界)NSWindow,我已经以编程方式添加了该自定义。出于某种原因,当我尝试调整窗口大小时,它会冻结,我无法调整窗口大小并打开菜单栏菜单。但是我仍然可以移动窗口,但不能单击其中的内容。奇怪的是,即使我打开了断点和NSZombieMode,也没有任何错误消息。所以我不知道问题是什么。

    // customWindow.m
    - (id)initWithContentRect:(NSRect)contentRect
                    styleMask:(NSUInteger)aStyle
                      backing:(NSBackingStoreType)bufferingType
                        defer:(BOOL)flag {
        // Using NSBorderlessWindowMask results in a window without a title bar.
        self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO];


if (self != nil) {


        if (![[SharedClass sharedManager] lastColor]) {
        [self setBackgroundColor:[NSColor colorWithRed:(float)252/255 green:(float)249/255 blue:(float)151/255 alpha:1]];

        [[SharedClass sharedManager] setLastColor:self.backgroundColor];
        } else {
        [self setBackgroundColor: [[SharedClass sharedManager] lastColor]];
        }

        [self setLevel:NSNormalWindowLevel];
        // Start with no transparency for all drawing into the window

        // Turn off opacity so that the parts of the window that are not drawn into are transparent.
        [self setOpaque:NO];
       // [self setBackgroundColor:[NSColor clearColor]];
        [self setHasShadow:YES];
        [self setMovableByWindowBackground:YES];
        [self makeKeyAndOrderFront:theTextView];
        panel = [NSColorPanel sharedColorPanel];
        [panel setTarget:self];
        [panel setColor:self.backgroundColor];

        [panel setAction:@selector(colorUpdate:)];
        [panel setShowsAlpha:YES];
        [self setDelegate:self];
        NSRect cFrame = [self frame];
        NSView *theView = [[NSView alloc] initWithFrame:cFrame];

        [self setContentView:theView];



         [self setMinSize:CGSizeMake(100, 100)];

    }


      return self;
    }

       - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize {

    exit.frame = NSMakeRect(2,(frameSize.height-12), 10, 10);
    palette.frame = NSMakeRect((frameSize.width-24),(frameSize.height-12), 10, 10);
    locker.frame = NSMakeRect((frameSize.width-12),(frameSize.height-12), 10, 10);
    theTextView.frame = NSRectFromCGRect(CGRectMake(0, 8, frameSize.width, (frameSize.height-20)));

    return frameSize;

}

- (void)windowDidResize:(NSNotification *)notification{
    NSLog(@"resized");
}

堆栈追踪:

0   DDHotKey                            0x00000001000044ed -[CustomWindow windowDidResize:] + 61
1   CoreFoundation                      0x00007fff9034245c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
2   CoreFoundation                      0x00007fff90232634 _CFXNotificationPost + 3140
3   Foundation                          0x00007fff8d7f59d1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
4   AppKit                              0x00007fff89117770 -[NSWindow _setFrameCommon:display:stashSize:] + 2885
5   AppKit                              0x00007fff891d4b73 -[NSWindow setFrame:display:animate:] + 641
6   DDHotKey                            0x000000010000a8c0 -[DDHotKeyAppDelegate setFrame:animated:] + 416
7   DDHotKey                            0x00000001000091ae __53-[DDHotKeyAppDelegate applicationDidFinishLaunching:]_block_invoke + 2318
8   AppKit                              0x00007fff895e5233 GlobalObserverHandler + 117
9   HIToolbox                           0x00007fff88d0ab6c _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1260
10  HIToolbox                           0x00007fff88d09fae _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 386
11  HIToolbox                           0x00007fff88d09e22 SendEventToEventTargetWithOptions + 43
12  HIToolbox                           0x00007fff88d46a9e _ZL29ToolboxEventDispatcherHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv + 1762
13  HIToolbox                           0x00007fff88d0b295 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 3093
14  HIToolbox                           0x00007fff88d09fae _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 386
15  HIToolbox                           0x00007fff88d1fcb6 SendEventToEventTarget + 40
16  AppKit                              0x00007fff890d71a2 _DPSNextEvent + 3001
17  AppKit                              0x00007fff890d5f68 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346
18  AppKit                              0x00007fff890cbbf3 -[NSApplication run] + 594
19  AppKit                              0x00007fff89048354 NSApplicationMain + 1832
20  DDHotKey                            0x0000000100007312 main + 34
21  libdyld.dylib                       0x00007fff8bd335c9 start + 1

0 个答案:

没有答案