0

Using iPad split view controller:

    (IBAction) textfieldEditingDidBeginAction:(id)sender{
        CGPoint scrollPoint = CGPointMake(0.0, 40);
        [_scroller setContentOffset:scrollPoint animated:YES];
    }

The text field scrolls 40 but after the keyboard appears it returns to previous position. This does not happen with same code in iPhone portrait view. ?? Also this seems to only happen for the first text field, the next one works and returning to the first it then works.

Ancient
  • 73
  • 4

1 Answers1

0

The problem is with iPad in landscape view it auto adjusts for textfield after the above scrolling done. In order to scroll with differing amounts in iPad landscape orientation I used the following which works:

    Boolean keyboardIsShown;
    UITextField *currentTextField;

    - (void)keyboardWasShown:(NSNotification*)aNotification){
     if(keyboardIsShown)
        return;
     [self scrollipadTextField];
     keyboardIsShown = yes;
     }

    -(IBAction) textfieldAEditingDidBegin:(id)sender{
        currentTextField=sender;
        if(keyboardIsShown)
            [self scrollipadTextField];

    }
    -(void)scrollipadTextField{
      int amount;
      if([[UIDevice currentDevice] userInterfaceIdiom]== 
          userInterfaceIdiomPad &&([[UIApplication sharedApplication]
          statusBarOrientation]==UIInterfaceOrientationLandscapeRight
          ||[[UIApplication sharedApplication] statusBarOrientation]==
          UIInterfaceOrientationLandscapeLeft)){ 
              if(currentTextField==_TextFieldA)
                  amount=70;
              if(currentTextField==_TextFieldB)
                  amount=90;//etc.
              CGPoint scrollPoint = CGPointMake(0.0, amount);
              [_scroller setContentOffset:scrollPoint animated:YES];
          }
      }
Ancient
  • 73
  • 4