Q:

how to adjust subviews height in iOS

I have 2 subview A and B.Both are Place in ScrollView.In ScrollView first Placed A and then Place B.A subview contains the uiimageview . B subview contains only UitextField.In A subview i can upload image for Gallery.using UIImagePickerController.I need is before uploading image on uiimageView No Need to show "A
" subview.B comes first on UIScrollView.if upload image. A subview comes first on uiimageView and then placed B subview.
       - (void)viewDidLoad
    {
        [super viewDidLoad];
        scrol=[[UIScrollView alloc]init];
        scrol.frame=CGRectMake(0, 100, self.view.frame.size.width, 250);
        scrol.delegate = self;
        scrol.scrollEnabled = YES;
        [self.view addSubview:scrol];
        scrol.contentSize =CGSizeMake(221, 650);
        scrol.backgroundColor=[UIColor blueColor];

        A=[[UIView alloc]init];
        A.frame=CGRectMake(10, 10, 221, 100);
        A.backgroundColor=[UIColor yellowColor];
        [scrol addSubview:A];

        B=[[UIView alloc]init];
        B.frame=CGRectMake(10, 120, 300, 100);
        B.backgroundColor=[UIColor grayColor];
        [scrol addSubview:B];

        firstimage1=[[UIImageView alloc]init];
        firstimage1.frame=CGRectMake(5, 10, 180, 80);
        firstimage1.backgroundColor=[UIColor redColor];
      //firstimage1.image = [UIImage imageNamed:@"Defult.png"];
        [A addSubview:firstimage1];

        UITextField *field1=[[UITextField alloc]init];
        field1.frame=CGRectMake(10, 10, 221, 30);
        field1.backgroundColor=[UIColor whiteColor];
        [B addSubview:field1];

        UITextField *field2=[[UITextField alloc]init];
        field2.frame=CGRectMake(10, 50, 221, 30);
        field2.backgroundColor=[UIColor whiteColor];
        [B addSubview:field2];

       getImages=[[UIButton alloc]init];
        getImages.frame=CGRectMake(0, 0, 28, 25);
        [self.view addSubview:getImages];
        [getImages addTarget:self action:@selector(aImages:) forControlEvents:UIControlEventTouchDown];
        [getImages setBackgroundImage:[UIImage imageNamed:@"Defult.png"] forState:UIControlStateNormal];

        img1 = [[UIImagePickerController alloc] init];
        img1.delegate = self;
        img1.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        img1.delegate = self;

        if(firstimage1.image){
            firstimage1.hidden=NO;
            A.hidden=NO;
            //if Image is there just set the A_View as your need.
            [A setFrame:CGRectMake(10, 10, 221, 100)];
            //and set B_View as per the Y co ordinate + height of A_View
            [B setFrame:CGRectMake(0, A.frame.origin.y+A.frame.size.height+10, 300, 100)];

        }

        else{
            firstimage1.hidden=YES;
            //And if image not there make it  hidden then make Aview hide and put your Bview at place of AView
            A.hidden=YES;
            [B setFrame:CGRectMake(10, 10, 300, 100)];
        }

    }
-(void)aImages:(id)sender
{

    actionSheet11 = [[UIActionSheet alloc]
                     initWithTitle:@"pick phot"
                     delegate:self
                     cancelButtonTitle:@"back"
                     destructiveButtonTitle:nil
                     otherButtonTitles:@"gallery", @"camera",
                     nil];
    actionSheet11.actionSheetStyle = UIActionSheetStyleBlackTranslucent;

    [actionSheet11 showInView:self.view];

}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    img1.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    int i = buttonIndex;
    switch (i) {
        case 0:
            img1.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            [self presentViewController:img1 animated:YES completion:^{}];
            break;
        case 1:
            img1.sourceType = UIImagePickerControllerSourceTypeCamera;
            [self presentViewController:img1 animated:YES completion:^{}];
            break;
        default:
            actionSheet11.hidden=YES;

    }
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [picker dismissModalViewControllerAnimated:YES];
    firstimage1.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

}

Before image loading no need to show A subview and B comes first in UIScrollView.after loading imageView using  UIImagePickerController A comes first and then place B .my code is before image loading it's B come first .But when uploading image  A subview it's now show
Please help me Thanks in Advanced   

A:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

firstimage1.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

 if(firstimage1.image){
        firstimage1.hidden=NO;
        A.hidden=NO;
        //if Image is there just set the A_View as your need.
        [A setFrame:CGRectMake(10, 10, 221, 100)];
        //and set B_View as per the Y co ordinate + height of A_View
        [B setFrame:CGRectMake(0, A.frame.origin.y+A.frame.size.height+10, 300, 100)];
  [picker dismissModalViewControllerAnimated:YES];

    }

    else{
        firstimage1.hidden=YES;
        //And if image not there make it  hidden then make Aview hide and put your Bview at place of AView
        A.hidden=YES;
        [B setFrame:CGRectMake(10, 10, 300, 100)];
    }

}

