Quiero seleccionar todo el texto del UITextField seleccionado cuando empiezo a editar. Probé el siguiente código pero esto no funciona.cómo hacer que el texto de UITextField esté seleccionado Prográficamente
[txt selectAll:self];
Quiero seleccionar todo el texto del UITextField seleccionado cuando empiezo a editar. Probé el siguiente código pero esto no funciona.cómo hacer que el texto de UITextField esté seleccionado Prográficamente
[txt selectAll:self];
Por favor verifique en el que ha colocado ... trate de poner el código anterior en
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
[textField selectAll:self];
}
Y también txt debe haber UITextField. Asimismo, no se olvide de establecer el delegado de txt como
txt.delegate = self;
en la que han declarado y añadir UITextFieldDelegate en .h como
@interface ViewController : UIViewController <UITextFieldDelegate>
Esto sin duda va a funcionar .... Se trabajó para mí.
Xyz respondió correctamente, pero no es necesario que use delegate. Puede simplemente conectar la acción desde el constructor de la interfaz en "La edición sí comenzó" y escribir allí el mismo código.
con la conexión no funcionaba para mí, pero con delegate lo hizo. – trickster77777
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
NSString * str = [textField.text stringByReplacingCharactersInRange:range withString:string];
return YES;}
cuando se inicia el uso de edición de este código para almacenarlo ur cadena
que está bien el trabajo para mí ... – Nit
http://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference /UITextField_Class/Reference/UITextField.html#//apple_ref/occ/instp/UITextField/clearsOnBeginEditing debes echar un vistazo a esto y a este http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/ UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html # // apple_ref/occ/intfm/UITextFieldDelegate/textFieldShouldClear: – Bala