开发者

Keypad in iphone is not going?

In my application, whenever i tap a textfield the keypad will be visible, i have used the

[textField resignFirstResponder];

t开发者_运维技巧o that textfield's IBOutlet, but still the return key in keypad is not enabled, so cannot make the keypad go away.It enables only after i type some Characters in the textfield.


First make sure you had set the "delegate" of your textfield in Interface Builder. You can set it by dragging its "delegate" attribute link to the File's Owner.

Keypad in iphone is not going?

Here titleFld is the name of my UITextField.

Setting delegate of your textfield will enable your compiler to call your "textfield delegate methods".

you can also do this programmatic by

[yourTextFieldName setDelegate: self];

//Set "self" if you have its delegates method in the same file.

If you want to move out your keyboard from the screen on its "return" key press then below code will do this task.

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
     [textField resignFirstResponder];
     return NO;
}

But make sure you set the delegate of your textfield...


I like keeping a button on the top-left of my "editable" views that resembles the iPad icon of "hide keyboard". This way, the user can always hides the keyboard when needed.

Also, if your UITextField is not editable, the keyboard will not show.


By default the return key in UITextField is not enabled until the user has typed some text. You can change this behavior so that the return key is always enabled by setting enablesReturnKeyAutomatically, either programatically with the UITextInputTraits protocol or in Xcode IB.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜