I am new to gaming apps. I am trying to implement question and answer game in which we have text fields. When you type a letter it automatically moves to the next text field, but it is not moving automatically for the second textfield. Can anybody help me to solve this issue?
int i=0,k=0;
while(i<len)
{
int y = 15 +k*44;
int j=0;
for(j=0; j<15;j++)
{
if (i>=len)
break;
if([[CharArray objectAtIndex:i]isEqualToString:@" "])
{
NSLog(@" space i value:%d",i) ;
NSNumber* spaceValues = [NSNumber numberWithInt:i];
[intArray addObject:spaceValues];
NSLog(@"intArray values :%@",intArray);
}
else
{
letterField = [[UITextField alloc] init];
// letterField.text = [CharArray objectAtIndex:i];
[letterField setContentMode:UIViewContentModeCenter];
[letterField setFrame:CGRectMake(30*(j+1)+1*j, y, 30,30)];
letterField.font = [UIFont systemFontOfSize:27.0f];
[letterField setTag:tagCount+300];
letterField.autocapitalizationType = UITextAutocapitalizationTypeNone;
letterField.delegate = self;
[answerView addSubview:letterField];
[letterField release];
tagCount ++;
}
i++;
}
k = k+1;
}
[viewToGuess removeFromSuperview];
[self.view addSubview:answerView];
[self.view bringSubviewToFront:answerView];
answerView.frame = CGRectMake(0, 904, 768, 100);
I am using this code for getting the TextField and I use keypress notification for this:
nextTag = nextTag + 1; //increment the tag value while key press.
Even though you are using the same logic for the second time it will not work, am i right? I think you forgot to allocate textfields
and
if you use this you may got what you want