hello!
i'm new programming. been reading lot , practicing i'm still in learning phase.
cocoa question (not ios), don't know if should post question here, if not please let me know cocoa forum go to.
have 1 main window, when click button there second window opens. got work i'm unable close first window.
here's code have works open second window:
bflagcontroller class made controls xib file second window.code:- (ibaction)showbflag:(id)sender { if (!bflagcontrol) { bflagcontrol = [[ bflagcontroller alloc] initwithwindownibname:@"bflag"]; } [bflagcontrol showwindow:self]; }
1 thing tried (i tried several solutions!) instead of closing, reopen first window when click on button on first window second window opens , first window reopens too, works! said should able replace "showwindow" command...? call it? well, thought should able replace showwindow "hidewindow" didn't work.
here tried:
this works instead of "showwindow" think should able use "hidewindow" (for main menu xib)code:- (ibaction)showbflag:(id)sender { if (!bflagcontrol) { bflagcontrol = [[ bflagcontroller alloc] initwithwindownibname:@"bflag"]; menucontrol = [[ menucontroller alloc] initwithwindownibname:@"mainmenu"]; } [bflagcontrol showwindow:self]; [menucontrol showwindow:self]; }
header file in case is:
thanks guys! hope can me or point me in right direction!code:#import <cocoa/cocoa.h> @class bflagcontroller; @interface menucontroller : nswindowcontroller { @private bflagcontroller *bflagcontrol; } - (ibaction)showbflag:(id)sender; @end
----------
i fixed it!
added [self close] @ beginning , worked...
so, how call this:
this method ? object?code:- (ibaction)showbflag:(id)sender { [self close]; if (!bflagcontrol) { bflagcontrol = [[ bflagcontroller alloc] initwithwindownibname:@"bflag"]; } [bflagcontrol showwindow:self]; }
thanks!
hi, should help.
but sure window not release when closes, otherwise bad access error.code:- (ibaction)click:(id)sender { if (_window.isvisible) { [_window close]; [_window2 makekeyandorderfront:nil]; } else { [_window2 close]; [_window makekeyandorderfront:nil]; } }
Forums Macs Mac Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
No comments:
Post a Comment