我在 Cocoa 界面中的表单之间切换非常困难。从我的初始表单及其委托中,我可以隐藏初始窗口,然后加载并显示第二个窗口及其所有属性。这正在工作......唉,在尝试返回初始窗口时,我隐藏了第二个窗口并且初始窗口没有返回......
这是我的 .h 和 .m 用于初始形式和 formTwo ......
。H
#import <Cocoa/Cocoa.h>
@class frmTwoDelegate;
@interface AppDelegate : NSObject {
@private
frmTwoDelegate *_frmTwo;
}
@property (assign) IBOutlet NSWindow *window;
- (IBAction)BtnSwitchAction:(id)sender;
@end
.m
#import "AppDelegate.h"
#import "frmTwoDelegate.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
...
}
- (IBAction)BtnSwitchAction:(id)sender {
if (!_frmTwo) {
_frmTwo = [[DecriptDelegate alloc] initWithWindowNibName:@"frmTwo"];
[_frmTwo setFrmStart:self];
}
[_frmTwo showWindow:sender];
[_window setIsVisible:NO];
}
@end
这是 frmTwo 的 .h 和 .m
。H
#import <Cocoa/Cocoa.h>
@class AppDelegate;
@interface frmTwo : NSWindowController{
@private
AppDelegate *frmStart;
__unsafe_unretained NSTextView *_TxtView;
}
@property (retain) AppDelegate *frmStart;
@property (assign) IBOutlet NSWindow *frmTwo;
@property (unsafe_unretained) IBOutlet NSTextView *TxtView;
- (IBAction)BtnOpenActionPreformed:(id)sender;
- (IBAction)BtnBackActionPreformed:(id)sender;
@end
.m
#import "frmTwo.h"
#import "AppDelegate.h"
@implementation frmTwo
@synthesize frmStart;
- (id)initWithWindow:(NSWindow *)window
{
...
}
- (void)windowDidLoad
{
...
}
- (IBAction)BtnOpenActionPreformed:(id)sender
{
...
}
- (IBAction)BtnBackActionPreformed:(id)sender {
[frmStart ShowWindow];
[_frmTwo setIsVisible:NO];
}
@end