【发布时间】:2015-01-15 06:14:01
【问题描述】:
我正在尝试构建一个没有情节提要的应用程序。因此,我想建立一个网格,使用户能够在界面方向和屏幕大小的功能上拥有一种动态布局。
请在下面找到两张图片,它们以两种不同的界面方向显示网格 - 纵向和横向。应该始终有一个固定的顶部、左侧和右侧边框 - 与屏幕尺寸和界面方向无关。
黄色网格仅代表一个标题 - 因此没有什么特别之处 - 唯一的例外是在纵向模式下它应该放在最左边的位置。
另外两个网格(单元格)应该包含两个不同的 UICollectionView。
[对不起:我刚刚发现我无法加载任何图像,因为我还是个新手! ]
主要问题如下: 您将如何构建主网格(使用提到的三个单元格)?
我想到的第一个想法是创建一个包含三个单元格的 UICollectionView。 但在这种情况下,我们将嵌套 UICollectionView,因此 CollectionView1 和 CollectionView2 嵌入在 MainCollectionView 中。主要问题在于主视图控制器中的三个不同的委托(用网格表示主视图) - 因此代码可能会被炸毁且不可读 - 仅想象方法(以及其他)
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { ... }
其中将包含要处理的三个不同的 collectionView 区别。
您是否有其他想法来实现这样的项目而无需过多地增加代码? 任何想法都非常感谢!
提前致谢!
<h2>Portrait</h2>
<table cellspacing=0 cellpadding=0 border=1>
<tr>
<td width=300 height=50 colspan=2 bgcolor="yellow" align="center">Headline</td>
</tr>
<tr>
<td width=100 height=100 bgcolor="blue" align="center">CollectionView 1</td>
<td width=200 bgcolor="red" align=center>CollectionView 2</td>
</tr>
</table>
<br/>
<h2>Landscape</h2>
<table cellspacing=0 cellpadding=0 border=1>
<tr>
<td width=50 height=80 bgcolor="yellow" align="center">Headline</td>
<td width=120 height=100 bgcolor="blue" align="center">CollectionView 1</td>
<td width=300 bgcolor="red" align="center">CollectionView 2</td>
</tr>
</table>
【问题讨论】:
-
"请在下面找到两张图片..." ?
-
抱歉 - 我无法上传任何图片!我刚刚创建了我的帐户..
-
您的 3 个网格当然不需要集合视图;只需使用自动布局来定位它们。如果没有看到您的图像,很难进一步建议您。有很多地方可以上传图片 - 你应该这样做,这样我们才能看到你想要的。
-
非常感谢,rdelmar!因此我会构建一个带有自动布局的 UIView,包含一个标签和两个不同的 CollectionViews?听起来比将所有内容都嵌入到超级 CollectionView 中要容易得多...
标签: objective-c ios8 xcode6 uicollectionview