mardi 4 août 2015

How to scroll the textfields when view is moved up?

I have text fields on registration screen so when keyboard appears i am moving up the view up.Now i want to scroll through text fields when i my view is moved up.

code for moving view up:

         CGRect rect = self.view.frame;
         rect.origin.y += 220;
         rect.size.height -= 220;
         self.view.frame = rect;

Here is hirecrchy

I have UIScrollView at top then under UIScrollView i have UIView i call it as contentView.On the contentView i have added some text fields.So my parent view is moved up fine but i am not able to scroll the textFields up & down when i view is up. I set the following value for scrolling.

    self.cvHeight.constant=500;
    self.scrollView.contentSize=CGSizeMake(500, 500);

Here cvHeight is outlet of height constraint of the contentView & scrollView is outlet of UIScrollView

Edit: When i am not moving the parentView up which is self.view then i am able to scroll through but if i move the parent view up then my textFields are not scrolling down they are just moving up.

Aucun commentaire:

Enregistrer un commentaire