私は .xib を持っていて、それには 1 つのウィンドウがNSToolbar
あり、すべて同じ xib の一部である複数のカスタム ビューがあります。ツールバー アイコンをクリックすると、ビューが切り替わりますが、そのビューにあるボタンやその他のオブジェクトは表示されません。
両方のビューのサイズが異なり、ウィンドウが調整されているため、ビューが切り替わっていることはわかっています
ビューを切り替えるコード:
NSInteger tag = [sender tag];
NSView *view = [self viewForTag:tag];
NSView *previousView = [self viewForTag: currentViewTag];
currentViewTag = tag;
NSRect newFrame = [self newFrameForNewContentView:view];
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0.1];
if ([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask)
[[NSAnimationContext currentContext] setDuration:1.0];
[[[self.window contentView] animator] replaceSubview:previousView with:view];
[[self.window animator] setFrame:newFrame display:YES];
[NSAnimationContext endGrouping];