CollectionView 的单元格不适合屏幕 [英] Cells of CollectionView don't fit in screen

查看:28
本文介绍了CollectionView 的单元格不适合屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 TableView 的单元格中有 CollectionView:

I have CollectionView in cell of TableView:

CollectionView

当我运行应用程序时在 iPhone 5s 上我看到(单元格不适合屏幕):

When I run app f.e. on iPhone 5s I see (cell doesn't fit at screen):

但是在向下和向上滚动后,我看到:

But after scroll down and up I see:

我知道重用,但如何从头开始显示单元格(适合屏幕)?

I know about reuse, but how to show cell from start as must (fit to screen)?

推荐答案

你需要重新加载你的收藏视图

You Need to reaload your Collection View

在你的 TableViewCell 实现方法中

In your TableViewCell Impleament Method

    func draw(_ rect: CGRect)
    {

// here you have to reaload your collectionView
        super.draw(rect)
    self.collectionView.realodData()

    }

通过调用它的 DrawRect 方法刷新你的 TableCell

refresh your TableCell By Calling its DrawRect Method

optional func tableView(_ tableView: UITableView, 
            willDisplay cell: UITableViewCell, 
               forRowAt indexPath: IndexPath)
{
  cell.setNeedsDisplay()
}

我希望这对你有用,

这篇关于CollectionView 的单元格不适合屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆