Reset NSTextField's text to empty string — setText: doesn't work

后端 未结 2 2096
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-25 04:30

I have an NSTextField, and I need a button to reset the text of the field. How would I do that? I have been trying this:

[textBox setText:@\"\"];
te         


        
相关标签:
2条回答
  • 2021-01-25 05:12

    Try this code:

    theLabel.text = @"this is some text";
    [self.view addSubView:theLabel];
    

    Here, the label is the text field.

    0 讨论(0)
  • 2021-01-25 05:22

    If it is OSX and NSTextField then use :

    [textBox setStringValue:@""];
    
    0 讨论(0)
提交回复
热议问题