Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 单击按钮时在cocoa Mac中创建新窗口时出现问题_Objective C_Cocoa_Macos - Fatal编程技术网

Objective c 单击按钮时在cocoa Mac中创建新窗口时出现问题

Objective c 单击按钮时在cocoa Mac中创建新窗口时出现问题,objective-c,cocoa,macos,Objective C,Cocoa,Macos,我有两个班,第一视图和第二视图。 在第一视图中 #import "SecondView.h" #import "FirstView" @interface FirstView : NSObject { IBOutlet NSButton *test; secondView *mySecond; } @property (nonatomic, retain) IBOutlet NSButton *test; -(IBAction) buttonClicked:(id)s

我有两个班,第一视图和第二视图。 在第一视图中

#import "SecondView.h" #import "FirstView" @interface FirstView : NSObject { IBOutlet NSButton *test; secondView *mySecond; } @property (nonatomic, retain) IBOutlet NSButton *test; -(IBAction) buttonClicked:(id)sender; @end #导入“SecondView.h” #导入“第一视图” @接口第一视图:NSObject{ IBN按钮*测试; 第二视图*mySecond; } @属性(非原子,保留)IBNSButton*测试; -(iAction)按钮勾选:(id)发送方; @结束 在第一视图中

#import "FirstView.h" @implementation FirstView @synthesize test; -(IBAction) buttonClicked:(id)sender{ NSLog(@"HELLO!!!"); if (!mySecond) { // If the second view controller doesn't exist yet, make it! mySecond = [[secondView alloc] init]; } [mySecond displayWindow]; } @end #导入“FirstView.h” @实现第一视图 @综合试验; -(iAction)按钮点击:(id)发送者{ NSLog(@“你好!!!”); 如果(!mySecond){ //如果第二个视图控制器还不存在,请创建它! mySecond=[[secondView alloc]init]; } [我的第二个显示窗口]; } @结束 在secondView.h中

#import @interface SecondView : NSObject { IBOutlet NSWindow *progressWindow; IBOutlet NSButton *testNew; } @property (nonatomic, retain) IBOutlet NSButton *testNew; - (void)displayWindow; -(IBAction) buttonClickedNew:(id)sender; @end #进口 @接口第二视图:NSObject{ IBS窗口*progressWindow; IBN按钮*testNew; } @属性(非原子,保留)IBNSButton*testNew; -(作废)显示窗口; -(iAction)按钮单击新建:(id)发送方; @结束 在secondView.m中

#import "SecondView.h" @implementation SecondView @synthesize testNew; - (id)init { if (self = [super init]) { NSLog(@"HAI!!"); [NSBundle loadNibNamed:@"Next" owner:self]; } return self; } - (void)displayWindow { if (![progressWindow isVisible]) { NSLog(@"ON SECOND!!!"); [progressWindow setIsVisible:YES]; [progressWindow orderFront:nil]; } } -(IBAction) buttonClickedNew:(id)sender { NSLog(@"GOOD!!!"); } @end #导入“SecondView.h” @实现第二视图 @合成新的; -(id)init{ if(self=[super init]){ NSLog(@“海!!”); [NSBundle loadNibNamed:@“下一个”所有者:self]; } 回归自我; } -(无效)显示窗口{ 如果(![progressWindow可见]){ NSLog(@“在第二个!!!”); [进度窗口设置可见:是]; [progresswindoworderfront:nil]; } } -(iAction)按钮单击新建:(id)发件人{ NSLog(@“好!!!”); } @结束 但我得到的结果是

Running… 2011-04-05 16:12:30.400 toDoListMac[6558:a0f] HELLO!!! 2011-04-05 16:12:30.402 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.404 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.406 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.408 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.409 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.410 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.411 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.413 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.414 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.415 toDoListMac[6558:a0f] HAI!! 运行… 2011-04-05 16:12:30.400 toDoListMac[6558:a0f]你好!!! 2011-04-05 16:12:30.402 toDoListMac[6558:a0f]HAI!! 2011-04-05 16:12:30.404 toDoListMac[6558:a0f]HAI!! 2011-04-05 16:12:30.406 toDoListMac[6558:a0f]HAI!! 2011-04-05 16:12:30.408 toDoListMac[6558:a0f]HAI!! 2011-04-05 16:12:30.409 toDoListMac[6558:a0f]HAI!! 2011-04-05 16:12:30.410 toDoListMac[6558:a0f]HAI!! 2011-04-05 16:12:30.411 toDoListMac[6558:a0f]HAI!! 2011-04-05 16:12:30.413 toDoListMac[6558:a0f]HAI!! 2011-04-05 16:12:30.414 toDoListMac[6558:a0f]HAI!! 2011-04-05 16:12:30.415 toDoListMac[6558:a0f]HAI!! secondView“init”正在调用无限次! 请…请…帮帮我


我想做的是。。。我想打开另一个关于特定操作的xib/窗口,比如说按钮单击。。。。请帮帮我…

Cocoa中有一个用于控制窗口的类:为什么不使用它?子类化NSWindowController将为您提供所有细节,然后您只需添加特定于您的用例的方法。简单得多

此外,还不清楚这些是单独的窗口还是单独的视图。如果是后者,你会想调查