- (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(@"你点击了切换模式"); }