Objective c 如何在代码中修改从库中拖动的NSButton?
我把一个按钮从图书馆拖到窗口。我将按钮链接到AppDelegate.h中的iAction,现在我想更改AppDelegate.m文件中按钮的标题,如何访问该按钮,我应该键入“self.window….setTitle:”还是其他什么?谢谢 如果您的Objective c 如何在代码中修改从库中拖动的NSButton?,objective-c,xcode,macos,cocoa,Objective C,Xcode,Macos,Cocoa,我把一个按钮从图书馆拖到窗口。我将按钮链接到AppDelegate.h中的iAction,现在我想更改AppDelegate.m文件中按钮的标题,如何访问该按钮,我应该键入“self.window….setTitle:”还是其他什么?谢谢 如果您的IBOutlet到NSButton是myButton,则使用 [self.myButton setTitle:@"New Title"]; 甚至 [_myButton setTitle:@"New Title"]; //If you are usin
IBOutlet
到NSButton
是myButton
,则使用
[self.myButton setTitle:@"New Title"];
甚至
[_myButton setTitle:@"New Title"]; //If you are using XCode4.4+ as @synthesize will be there creating _myButton.
正如您所说,您已将按钮连接到iAction,您只需执行以下操作:
-(IBAction)buttonClick:(id)sender{
sender.title=@"New Title";
}
你知道怎么做吗?我知道了!我过去认为按钮只能有IBAction。thanks@AnoopVaidya@马哈茂德法耶兹,我明白了……哈哈