【发布时间】:2014-02-15 11:16:13
【问题描述】:
我正在尝试构建一个日历,我需要在其中为每一天插入不同的列表。我认为当月每个数字标签下的集合视图将是最好的,并且到目前为止它有效。我只有在将新项目添加到集合视图时遇到问题。它没有增长,我必须向下滚动。
我正在寻找一种解决方案,可以在不触及项目高度的情况下动态扩展集合视图的高度。由于页面上有 40 个“迷你”集合视图,我需要能够一次增加所有集合视图的高度,而不是让每个集合视图都增长到下面的文本之上。
这是我的 viewDidLoad 代码:
houseNameLabelList = [[NSArray alloc] initWithObjects:@"House 1", @"House 2", @"House 3", @"House 4", @"House 5", nil]; // The array of the titles I want to display
NSInteger rowCount = [houseNameLabelList count];
CGFloat height = rowCount * 17; // 17 is the height of each item in the collection view
self.myCollectionView.frame = CGRectMake(self.myCollectionView.frame.origin.x, self.myCollectionView.frame.origin.y, 45, height); // 45 is the width of my collection view
当然,我将委托和数据源设置为“self”。
集合视图的初始高度是 51(3*17 表示 3 个项目),我希望它增长到 85(我的数组中的 5 个项目为 5 * 17)。
我该怎么做? 感谢您的提示
【问题讨论】:
标签: height collectionview