How do I set the firstresponder?

后端 未结 3 1995
无人及你
无人及你 2021-02-18 22:59

I have a view built through IB, there\'s a text view and and button on it. When the view shows up I would like to have the keyboard to be already displayed.

I tried to s

3条回答
  •  遇见更好的自我
    2021-02-18 23:41

    I know this is tagged as cocoa-touch but this is highly ranked in Google and I ran into trouble with using -becomeFirstResponder on OS X; it did nothing. From the NSResponder documentation,

    Use the NSWindow makeFirstResponder: method, not this method, to make an object the first responder. Never invoke this method directly.

    So on OS X use,

    [[myView window] makeFirstResponder:myView];
    

提交回复
热议问题