Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在另一个视图中插入contentView将使单元格接触无效_Ios_Swift - Fatal编程技术网

Ios 在另一个视图中插入contentView将使单元格接触无效

Ios 在另一个视图中插入contentView将使单元格接触无效,ios,swift,Ios,Swift,我试图在UICollectionViewCell中的单元格内容后面添加滚动视图。然而,一旦我添加了它,我就选择了Cell。。。不再工作了。有什么想法吗 func build(){ scrollView = UIScrollView(frame: self.bounds) scrollView.scrollEnabled = true //Move the cell contents into the scrollview self.backgroundView

我试图在UICollectionViewCell中的单元格内容后面添加滚动视图。然而,一旦我添加了它,我就选择了Cell。。。不再工作了。有什么想法吗

func build(){
    scrollView = UIScrollView(frame: self.bounds)
    scrollView.scrollEnabled = true

    //Move the cell contents into the scrollview
    self.backgroundView = scrollView
    self.contentView.removeFromSuperview()
    scrollView.addSubview(self.contentView)

    var contentSize = self.bounds
    contentSize.size.width += 100

    self.scrollView.contentSize = contentSize.size
}

UICollectionViewCell
中删除
contentView
不是一件好事。考虑添加<代码> ScLabVIEW < /代码>作为“代码>内容视图< /代码>的子视图。我正在进行扫描以显示单元格。所以我需要将单元格的所有内容添加到scrollview中。不,我认为视图层次结构是这样的。contentView->scrollView->containerView。您可以将所有内容放在containerView中,它会在scrollView中滚动。或者根本不使用scrollView。使用
uipangestureerecognizer
更改
contentView
center.x
属性。但如果我想知道运行时单元格上有什么内容,该怎么办?它不是来自数据源对象吗?您可以从
UICollectionView
中“indexPath”并查找数据