iphone keyboard without textview

后端 未结 4 1004
难免孤独
难免孤独 2020-12-15 01:22

is it possible to bring up the keyboard in an iphone app without a textview? or will i have to have an invisible textview?

if so, how do you programatically create a

4条回答
  •  遥遥无期
    2020-12-15 02:02

    The only (valid) way to show the keyboard is to have a textfield that is first responder. You can hide it and make it first responder programmatically by calling becomeFirstResponder on the hidden textfield.

    You can create a UITextView programmatically by doing something like this (assume aRect and view exist)

    var textView = [[[UITextView alloc] initWithFrame:aRect] autorelease];
    [view addSubview:textView];
    
    [textView becomeFirstResponder];
    

提交回复
热议问题