6

I made the scroll view with lots of text fields in it. I added the updated TPKeyBoardAvoidingScrollView and added it in the scroll view's file owner. I added the outlet in .h file, synthesized in .m file and added the line [self.view addSubview:scrollObject];

The issue is the view starts scrolling only after keyboard appears. It does not scroll as soon as the view is loaded.

Any solution for this?

Adding these lines did not solve my query

scrollViewObj = [[UIScrollView alloc] init];
  self.automaticallyAdjustsScrollViewInsets = NO;
    [scrollViewObj setScrollEnabled:YES];
    scrollViewObj.maximumZoomScale = 4.0;
    scrollViewObj.minimumZoomScale = 0.75;
    scrollViewObj.clipsToBounds = YES;
Deepak Thakur
  • 3,453
  • 2
  • 37
  • 65
  • It's tough to understand your situation without more information. Please provide more detail. Also, what is `TPKeyBoardAvoidingScrollView`? – Alfie Hanssen Oct 31 '13 at 14:51
  • i solved that issue by adding [textfield becomefirstresponder]; in viewDidAppear to display the keyboard as soon as the view is loaded. Still don't think that TPKeyBoardAvoidingScrollView should be. – Deepak Thakur Oct 31 '13 at 14:54

2 Answers2

0

do you have :

scrollViewObj.contentsize > scrollViewObj.frame.size.height ?

also how do you adding those lot of textFields into? (programmatically/storyboard)?

sajmon
  • 21
  • 2
0

I fixed this problem by adding the following at the end of viewDidLoad:

scrollViewObj.contentInset = UIEdgeInsetsMake(0, 0, self.view.bounds.size.height * 2, 0);

The order of the parameters are top, left, bottom, right. Experimenting indicates that the bottom edge inset must be set to a value more than the height of the content. The other edge insets work best if set to 0.

Bruce Patin
  • 2,049
  • 1
  • 12
  • 7