Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSToolbarItem: "Make sure this toolbar item has a valid frame/min/max size"?

Since upgrading to Mac OS Sierra and the new XCode version I get the following error every time I launch my application for every one of the NSToolbarItems:

Example 1:
2016-09-29 12:46:58.659879 AppTest[] NSToolbarItem (<NSToolbarItem: >) had to adjust the size of <NSPopUpButton: > from {130, 26} to the expected size of {132, 27}. Make sure that this toolbar item view has a valid frame/min/max size. This is an app bug, please do not file a bug against AppKit or NSToolbar! Break on _NSToolbarAdjustedBorderedControlSizeBreakpoint
Example 2:
2016-09-29 12:46:58.666074 AppTest[] NSToolbarItem (<NSToolbarItem: >) had to adjust the size of <NSButton: > from {60, 25} to the expected size of {62, 27}. Make sure that this toolbar item view has a valid frame/min/max size. This is an app bug, please do not file a bug against AppKit or NSToolbar! Break on _NSToolbarAdjustedBorderedControlSizeBreakpoint

I tried messing around in StoryBoard changing the size with no luck, when I searched around I found a couple of people having this issue as well with the new OS but no helpful answers.

Anyone facing the same issue, any advice?

Thanks a lot,

Marc

like image 213
MMV Avatar asked Sep 29 '16 11:09

MMV


3 Answers

Was not able to solve this in interface builder. However overriding minSize in subclass of NSToolbarItem solved the issue.

- (NSSize)minSize
{
    if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) {
        /* Overriding this getter seems to be the only solution for runtime error logs like: NSToolbarItem (<APMRegularToolbarItem: 0x60e000039460>) had to adjust the size of <NSButton: 0x60f0001acce0> from {40, 25} to the expected size of {42, 27}. Make sure that this toolbar item view has a valid frame/min/max size. This is an app bug, please do not file a bug against AppKit or NSToolbar! Break on _NSToolbarAdjustedBorderedControlSizeBreakpoint
         */
        return NSMakeSize(42, 27);
    }
    else {
        return [super minSize];
    }
}
like image 178
Marius Avatar answered Oct 04 '22 07:10

Marius


For me, changing the maximum size of the NSToolbaritem as mentioned above did not work. But changing the minimum size of it did the trick. Warning message is now gone.

like image 36
vomi Avatar answered Oct 04 '22 07:10

vomi


Found the problem! The problem is that in IB in Xcode, the minSize fields are bound only one-way to the XIB source. If you change the NSToolbarItem minSize in IB, it saves it appropriately. But if you reopen the panel, either by reopening Xcode, reopening the project or even just reopening the properties panel, it shows the default values again. So the properties panel at this point might show W 127 H 25 even though the source of XIB file (the XML) shows W 129 H 27 (whatever values you tried to set last time). So the minSize field values in Xcode IB's Properties panel aren't set correctly. This leads to the confusing situation that saving after reopening the Properties panel of the NSToolbarItem, your changes will be overwritten again. It's an Xcode bug it seems. @Marius' answer solves this runtime, the other solution is not to open the NSToolbarItem properties again after setting the minSize.

like image 37
Joeri van Veen Avatar answered Oct 04 '22 05:10

Joeri van Veen