In SWIFT, dynamic height for UItextview in UIcollectionView

守給你的承諾、 提交于 2019-12-11 02:57:32

问题


I am using two collectionview. One for displaying story. Another for calendar. It will display last 15 days. I need left to right scroll, so content offset i used. Text I am receiving from parse, according to that text size, textview frame has been displayed. For story view, paging is enabled. So one by one story has been displayed. But, bottom, having date view, 4 dates displayed at a time. If I click 10th date, story view gets scroll to 10th story. But at that time, I textview is not displaying its content size. It is displaying its own size. But, if we scroll one by one, textview displaying exact size. Kindly guide me.

My Coding below.

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    if(collectionView == date_collection_view)
    {
    }
    else
    {
        cell.reading_area_txtvw.text = self.myConList.objectAtIndex(indexPath.row) as? String
        read_height = cell.reading_area_txtvw.contentSize.height // It is working when we scroll one by one story
        cell.reading_area_txtvw.frame = CGRect (x: 10 , y: 63, width: 300.0, height: read_height)
    }
}

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
    if(collectionView == date_collection_view)
    {
        story_collection_view.scrollToItemAtIndexPath(indexPath, atScrollPosition: UICollectionViewScrollPosition.None, animated: true)

        date_collection_view.scrollToItemAtIndexPath(indexPath, atScrollPosition: UICollectionViewScrollPosition.None, animated: true)

        //If we click some dates, exact story is displaying. But, textview content size is not displaying. Same size, what we have given in storyboard, that is displaying.
    }
}

来源:https://stackoverflow.com/questions/28325384/in-swift-dynamic-height-for-uitextview-in-uicollectionview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!