Search code examples
iphonexcodecrossword

move between uitextview


After several attempts, I decided to write because I just can not figure out how to make it work. I refer to the crossword puzzle. what I did is this:

- (void) viewDidLoad{
    int move = 15;
    int h = 50;
    for (int i = 0; i < 416; i++){
        move = move + 36;
        fieldUno = [[UITextField alloc] init];
        fieldUno.tag = i;
        [fieldUno viewWithTag:i].frame = CGRectMake(move, h, 35, 35);
        [fieldUno setBackgroundColor:[UIColor purpleColor]];
        [fieldUno setTextAlignment:UITextAlignmentCenter];
        [fieldUno setFont:[UIFont fontWithName:@"Times New Roman" size:30]];
        [fieldUno setDelegate:self];
        [self.view addSubview:[fieldUno viewWithTag:i]];
        [fieldUno release];
        if (i == 25) h = h + 36, move = 15;
        if (i == 51) h = h + 36, move = 15;
        if (i == 77) h = h + 36, move = 15;
        if (i == 103) h = h + 36, move = 15;
        if (i == 129) h = h + 36, move = 15;
        if (i == 155) h = h + 36, move = 15;
        if (i == 181) h = h + 36, move = 15;
        if (i == 207) h = h + 36, move = 15;
        if (i == 233) h = h + 36, move = 15;
        if (i == 259) h = h + 36, move = 15;
        if (i == 285) h = h + 36, move = 15;
        if (i == 311) h = h + 36, move = 15;
        if (i == 337) h = h + 36, move = 15;
        if (i == 363) h = h + 36, move = 15;
        if (i == 389) h = h + 36, move = 15;

but now I do not know how to make the next one in reading, with becomeFirstResponder. I wanted to do something quite simple and you can select only the first text box. then do a check on two different arrays to see if the result is wrong or not, but this is already much easier.

what methods should I call? think for example if the tag 1 to tag 5 will be a word, and tag another 7 to 12, I will have to do different if, for each field? and if I were to write vertically? I do not know if I'm on the right track, I was advised to use draw rect but I would follow this way

I apologize if the code is a little messed up.

I did not know how else to do


Solution

  • I'm not completely certain what you're asking, but I'll take a stab at answering anyway. You can add [nextTextField becomeFirstResponder]; to the delegate method textFieldDidEndEditing that takes the user to whichever textField you think he should be at next.