1
votes

I'm currently trying to center a UIScrollView inside of my UIViewController class and am having a problem.

The UIViewController is inside of a tab bar and a nav bar, so it is 367 pixels tall on iPhone and 320 pixels wide.

The UIScrollView is placed inside of that UIViewController, and the UIScrollView is being loaded from another UIViewController class responsible for displaying content.

Now, my goal is to make the scrollview 10 pixels less in width than the containing UIViewController so that the scroll view does not take up the width of the screen.

However, in Interface Builder, when I select 300 as my UIScrollView width, and in my implementation file for the containing UIViewController, when I set the width as 300,

[scrollView setContentSize:CGSizeMake(300, 1500)];

the end result is a full-screen scroll view instead of one cut off by 5 at each side.

Any ideas on how to take care of this?

Thanks.

1

1 Answers

0
votes

You can use uiscrollview's

@property(nonatomic) UIEdgeInsets contentInset

However, it is possible that when you are using in the class1 the scroll view from the class2, scroll view frame/content size are read from class2 object instead of class1 nib.