【发布时间】:2016-04-18 08:54:57
【问题描述】:
我有一个子类 UICollectionViewController,我在应用程序的多个位置使用它。将其直接添加到视图中时,它看起来是正确的(水平对齐、垂直滚动),如下所示:
self.activityFeed = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"activityFeed"];
self.activityFeed.view.frame = CGRectMake(0, 76, self.view.frame.size.width, 50);
[self.view addSubview:self.activityFeed.view];
但是,将其添加到 UIScrollView 时,由于某种原因,对齐方式会发生变化,如下所示:
self.activityFeed = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"activityFeed"];
self.activityFeed.view.frame = CGRectMake(0, 300, self.view.frame.size.width, 50);
[self.scrollContentView addSubview:self.activityFeed.view];
// scrollContentView is a view that holds all of my subviews in the scrollview
// also, activityFeed.view has no autolayout constraints attached
我知道约束在滚动视图中的作用有很大不同,为了使我的集合视图看起来与第一张图像中的相同,我需要做些什么不同的事情吗?
【问题讨论】:
标签: ios objective-c uiscrollview uicollectionview