Ortensia C.
Ortensia C.

Reputation: 4716

UIView with different height between xib and code

In the iPad version of my application I have a UIView, subview of a TPKeyboardAvoidingScrollView, created by the xib that has as its frame (0.0, 1024, 437). When you run the application in the output frame is become (0.0, 1024, 800) accordingly with almost twice the height it should have. What does it mean? How can I solve it?

The code:

   //self.scrollView is a TPKeyboardAvoidingScrollView

   CGFloat width = self.scrollView.frame.size.width;//is correct
   CGFloat progY = 0;

    self.view1.frame = CGRectMake(0, progY, width, 
                          self.view1.frame.size.height);
    [self.scrollView addSubview:self.view1];

    progY+= self.view1.frame.size.height;
   //is correct, the height is equal to that of the xib

    self.view2.frame = CGRectMake(0, progY, width, self.view2.frame.size.height);
    NSLog(@"the frame of view2 is %@", NSStringFromCGRect(self.view2.frame));
    //the frame of view2 is {{0, 215}, {1024, 800}}
    //the height would be 437 as in xib

    [self.scrollView addSubview:self.view2];

    progY+= self.view2.frame.size.height;//is wrong

    //....

Upvotes: 0

Views: 1437

Answers (1)

TheEye
TheEye

Reputation: 9346

The base view in your XIB probably has the wrong autoresizing properties et.

Have a look at the base view's autoresizing settings in the Size Inspector - it should not be connected to the lower end of the screen, and also not change height dynamically, then you're fine.

Upvotes: 3

Related Questions