I have a MacOS Objective C project in Xcode with two Nib files. In the second Nib I have an NSPanel object. I have created an outlet for it as shown below:
@property (weak) IBOutlet NSPanel *Settings;
If I check "Visible at launch" in the Identity inspector it appears at launch. However if I uncheck this option and try and make it visible from a toolbar item click using the action from the toolbar click as follows:
- (IBAction)SettingsClick:(id)sender {
[_Settings setIsVisible:true];}
the panel does not become visible. I've also tried the code
[self.Settings makeKeyAndOrderFront: self];
in the action but this does not result in the panel becoming visible either.
If I make the panel visible at launch, closing it closes the second Nib-defined window as well.
If change the way the second Nib is displayed from
[[self loadWithNibNamed:@"ImageSplit" owner:self ] display];
to
[[self loadWithNibNamed:@"ImageSplit" owner:self ] setNeedsDisplay:true];
then the toolboxitem action
[self.Settings makeKeyAndOrderFront: self];
shows the Settings panel OK when the toolbox item is clicked the first time. However, if the second Nib is closed and re-opened, clicking on the toolbar item does not show the Settings panel. Also the panel does not always appear - sometimes a Clean Build folder is required, sometimes more than once so the problem is still not solved.
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.