0

我将一个按钮从库中拖到窗口中。我在 AppDelegate.h 中有链接到 IBAction 的按钮,现在我想更改 AppDelegate.m 文件中按钮的标题,如何访问该按钮,我应该键入“self.window .... setTitle:" 还是什么?谢谢!

4

1 回答 1

2

如果你 是IBOutlet然后使用NSButtonmyButton

[self.myButton setTitle:@"New Title"];

甚至

[_myButton setTitle:@"New Title"]; //If you are using XCode4.4+ as @synthesize will be there creating _myButton.

正如您所说,您已将按钮连接到 IBAction,那么您可以简单地执行以下操作:

-(IBAction)buttonClick:(id)sender{
    sender.title=@"New Title";
}
于 2013-03-09T14:45:36.840 回答