简体   繁体   中英

Modal NSWindow Notification after becoming visible again

I am on objectiveC, OSX, not iOS. XCode 8.3

I have a preferences Window (custom NSWindow) that opens as a modal on my main window.

The preferences window itself contains a view with tabs. The tab height changes the windows size whenever one is clicked.

First Tab clicked:

在此处输入图片说明

Second Tab clicked:

在此处输入图片说明

Now if someone hides the application in the dock and activates it again, the preferences window becomes active with the height of tab 1, even if tab 2 is still active. So the content gets cut off.

在此处输入图片说明

What i need is some kind of notification that gets triggered on becoming active/visible again to trigger a resize of the window before it gets displayed.

I tried it with these notifications in my NSWindow subclass (with NSWindow delegate set).

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

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

- (BOOL)canBecomeKeyWindow{
    return YES;
}

- (BOOL)canBecomeMainWindow{
    return YES;
}

But none of them worked. Is it because it's a modal window? Any help appreciated.

I found it. My mistake - my tabViewController triggered a resize on viewWillAppear with always the first tab. I changed that to the current selected tab and that was it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM