ios 将子视图添加到不在中心的滚动视图

ios Adding SubView to a ScrollView not on center

我有一个 iOS 项目,可以将子视图添加到笔尖。使用自动布局将子视图的内容设置为中心,但是当将子视图添加到滚动视图时,子视图的内容不在中心。 这是代码:

UIView *scroller = [[[NSBundle mainBundle] loadNibNamed:@"scroller" owner:self options:nil] objectAtIndex:0];
[self.view addSubview:scroller];

CGSize size = self.view.bounds.size;
NSLog(@"view size: %f", size.width);
self.scrollView.contentSize = CGSizeMake(size.width, size.height);
self.scrollView.frame = CGRectMake(0, 0, size.width, size.height);
self.myView.frame = CGRectMake(0, 0, size.width, size.height);
self.scrollView.bounds = self.myView.bounds;
[self.scrollView addSubview:self.myView];

输出如下: http://imgur.com/h6cejTA

我也上传了我的项目: http://www.filedropper.com/myproject

我解决了。这是我使用的代码:

UIView *scroller = [[[NSBundle mainBundle] loadNibNamed:@"scroller" owner:self options:nil] objectAtIndex:0];
[self.view addSubview:scroller];

CGSize size = self.view.bounds.size;
self.scrollView.contentSize = CGSizeMake(size.width, size.height+200);
self.myView.frame = CGRectMake(0, 0, size.width, size.height);
[self.scrollView addSubview:self.myView];