-1

I have a form that I put inside a scrollview. On this form I have a couple of buttons that puts up a dateTime picker or a pickerView when I press on them. But I was wondering if I can but my form up to show the text that at the moment is behind the pickerView.

I know you can do that with a UITextfield. You can find the explanation over here.

Hope that anyone can help me!

Kind regards!

Steaphann
  • 2,797
  • 6
  • 50
  • 109
  • chk my answer http://stackoverflow.com/questions/13620898/how-to-set-the-textview-move-up-animation-based-on-keyboard-in-the-custom-uiview/13621478#13621478 – Rajneesh071 Dec 03 '12 at 08:53
  • 1
    Answer is in your own question. You need to do set contentOffset of scroll view in action method of your buttons instead of doing it in keyBoard notification callbacks (as it is done in Apple docs you referred to) – Atif Azad Dec 03 '12 at 09:01

2 Answers2

3
-(IBAction)btnDate_Clicked:(id)sender
{

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    yourScrollView.frame = CGRectMake(0, -100, 320, yourScrollView.frame.size.height);  // set frame which you want   
    [UIView commitAnimations];


}

and when you want to set original position of scroll then again set the scrollview frame with my animation code for ex.

-(IBAction)btnDone_Clicked:(id)sender
{

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    yourScrollView.frame = CGRectMake(0, 0, 320, yourScrollView.frame.size.height);  // set frame which you want   
    [UIView commitAnimations];


}
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
0

use the scrollRectToVisible:animated: method of UIScrollView

Pranjal Bikash Das
  • 1,092
  • 9
  • 27