I've got a few instances of UITextField
that I've added to some cells in a UITableView
. I'm using the UITextField
delegate to select all text in the textfield
, like so:
-(void)textFieldDidBeginEditing:(UITextField *)textField {
[textField selectAll:self];
}
The problem I'm seeing is that I don't want the selection popup to appear the first time you touch the cell. I want to be able to edit the text, so I don't want to use becomeFirstResponder
.
What you need is UIMenuController
and you can hide it using - (void)setMenuVisible:(BOOL)menuVisible animated:(BOOL)animated
so after your [textField selectAll:self];
call the above method to hide the menu.
EDIT
After a little search on google it seems that you will need to create a subclass of UITextField and override the - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
and return NO
from this in order to hide the UIMenuController
.
I can't test this right now since I'm not at my office but you should also try the following line [UIMenuController sharedMenuController].menuVisible = NO;
before you start to implement a subclass of UITextField
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.