我正在尝试使用以下代码向我的单元格添加UITextVIew
:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("message_cell" , forIndexPath: indexPath) as! DisplayMessageCollectionViewCell
let messageTextView: UITextView = {
let textView = UITextView()
textView.font = UIFont.systemFontOfSize(18)
textView.text = chat_m[indexPath.row].text
textView.backgroundColor = UIColor.clearColor()
return textView
}()
cell.addSubview(messageTextView)
cell.backgroundColor = UIColor.lightGrayColor()
return cell
问题是它在屏幕上不可见。以前我使用故事板添加了它,但是出现了这个问题:UITextView in CollectionView Wrapping