【发布时间】:2014-12-05 11:08:38
【问题描述】:
我正在尝试创建一个包含多个单元格的视图集合。
第一个单元格必须包含时间线。
正如您在图像中看到的,无法水平打印时间线。
如何水平打印此单元格?
我的代码:
class ViewController: UIViewController, UICollectionViewDataSource,UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
var year = 2000
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 200
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSize(width: 97, height: 33)
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as MyViewCell
cell.textView.text = "\(year)";
year++;
return cell
}
}
【问题讨论】:
-
所有单元格水平?
-
并非如此。一共三个单元格,只有两个水平的和一个垂直的。在这个链接中:你可以看到我在做什么:code4app.net/ios/Static-column-table/50fe649d6803fa7b65000001
-
减小单元格大小,使两个单元格进入水平宽度。并在部分中分配三个单元格。
-
noOfYears/3 应该是你的部分。
-
对不起,我不明白。为什么要缩小细胞大小?我只是希望单元格在水平方向一个接一个地打印
标签: ios swift uicollectionview