Reputation: 909
I have several UITextfields
in one of my app's Viewcontroller
. It works fine and I can type letters on those textfields. But sometimes cursor appears on the UITextfield
but cannot type any letter on that. This does not happen always. What I do is when this problem occurs I delete that particular UITextfield
and re-add a new UITextfield
. But after performing several functionalities again that also gets the same problem.
What is the reason for this? And how to solve this problem. Please please help me. I'm fighting with this for several days. Those are in Editable and User interactions are already enabled for these.
These are the delegates which I used
-(void)textFieldDidBeginEditing:(UITextField *)textField {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
if ([UIScreen mainScreen].bounds.size.height==480) {
if (textField.tag==7) {
CGPoint npoint=originalCenter;
npoint.y=180;
self.view.center=npoint;
}
else if (textField.tag==8)
{
CGPoint npoint=originalCenter;
npoint.y=125;
self.view.center=npoint;
}
else{
self.view.center=originalCenter;
}
}
else{
if (textField.tag==8)
{
CGPoint npoint=originalCenter;
npoint.y=250;
self.view.center=npoint;
}
else{
self.view.center=originalCenter;
}
}
[UIView commitAnimations];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.center=originalCenter;
[UIView commitAnimations];
[textField resignFirstResponder];
return NO;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
if ([textField isEqual:txtPhonenumber]) {
NSUInteger newLength = [textField.text length] + [string length] - range.length;
return (newLength > 9) ? NO : YES;
}
else if ([textField isEqual:txtVerification])
{
NSUInteger newLength = [textField.text length] + [string length] - range.length;
return (newLength > 4) ? NO : YES;
}
}
Upvotes: 0
Views: 5745
Reputation: 698
Can't say without looking at implementation, but it may be due to your code in some of UITextField
delegate methods especially -
if you return NO in – textFieldShouldBeginEditing:
or
did something in wrong textField:shouldChangeCharactersInRange:replacementString
Upvotes: 3