【发布时间】:2014-12-30 08:55:17
【问题描述】:
UICollectionView 的帮助 我正在使用 textview 来显示内容。 Collectionview 包含 10 个单元格。我无法根据该 textview 的内容大小指定 textview 的高度。我一次显示一个单元格。在故事板中,textview 高度为 240px。但我需要根据内容大小扩展内容视图。我的代码如下。但如果我跑步,
错误接收为:FATAL ERROR WHILE UNWRAPPING reading_access has nil value。请指导我!
// MAIN CLASS
class read_page: UIViewController, UICollectionViewDataSource,UICollectionViewDelegate
{
@IBOutlet var reading_collection_view: UICollectionView!
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section:
Int) -> Int {
return 10
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath:
NSIndexPath) -> UICollectionViewCell {
var cell = story_collection_view.dequeueReusableCellWithReuseIdentifier("story_read",
forIndexPath: indexPath) as story_reading_cell
cell.reading_area_txtvw.frame.size.height = 750
return cell
}
// This code is working. But, from 3rd cell onwards it is working. When we compile,
// textview does not change. After scrolling two more cells, it is working. How to get
// its size from first cell onwards? How to change cell size?
}
【问题讨论】:
标签: swift ios8 uicollectionview uitextview