iphonexcodeuiscrollviewxibfreeform

xcode 4:6 load interface builder freeform with scroll view height bigger then iPhone screen


I have a view controller that loads a free form with the size 320 x 950. But the screen of the iPhone is only 480 pixels height.

I created a xib file and set on :

Utilities > Show the attributes inspector > Simulated metrics > Size > Freeform

On the view I set a UIScrollView and inside the scroll view I put the elements. Run the application and you will see the current output (it displays only the bottom of the view and the scroll isn't enabled).

I created IBOutlet UIScrollView * motherScrollView & reference it to the scroll view from xib. In code I set:

[mothersScrollView setContentSize:CGSizeMake(320, 950)];

Freeform image

! [Freeform image] (https://i.sstatic.net/yL7aP.png)

Run result

! [Run result] (https://i.sstatic.net/EYzsL.png)

Thank you a lot for any advice or implementation.


Solution

  • The best way and easiest way that I found: Set in IB the elements that fit inside a 3.5 inch screen. Make sure that the UIScrollView is referenced as IBOutlet and add programmatically the other elements on the scrollview. Set the frame of the screen for the scrollview and the content size for it. The advantage of using Interface builder for the first elements is that you save a lot of time.