Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why i'm getting "titlebarViewController not supported for this window style" exception when trying to add title bar accessory view

I'm trying to add title bar accessory view in app. For one of the beta testers i'm getting exception:

 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'titlebarViewController not supported for this window style' 

Exception happens in this line:

[window addTitlebarAccessoryViewController:vc];

Any ideas what's causing it, can i somehow check for crash condition in code and disable adding title bar accessory view if that condition occurs ?

like image 570
Krzysztof Avatar asked Nov 22 '25 04:11

Krzysztof


1 Answers

Turns out the exception happens when the window does not show title bar (NSTitledWindowMask == 0). So check for this can be done as follow:

NSWindow *window = self.view.window;
if ((window.styleMask &  NSTitledWindowMask) == 0){
    // Ignore if no title bar on window
    return;
}

But there was another issue in our code. When app was launch in full screen mode self.view.window was returning different window - NSToolbarFullScreenWindow as the view was part of the other title bar accessory view (toolbar) and in fullscreen it had different window parent.

like image 165
Krzysztof Avatar answered Nov 24 '25 22:11

Krzysztof



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!