- (void)viewDidLoad { [super viewDidLoad]; NSLog(@"Hello world!"); // 設置按鈕 [self setbutton]; } -(void)setbutton{ NSButton *button = [[NSButton alloc]init]; button.frame=CGRectMake(100, 100, 64, 64); [button setTitle:@"確認簽收"]; [button setTarget:self]; [button setAction:@selector(buttonClick)]; [self.view addSubview:button]; } -(void)buttonClick{ NSLog(@"你點擊了切換模式"); }