Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.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 UICollectionView不允许完全滚动---最后几行被切断_Ios_Xcode_Swift_Uicollectionview - Fatal编程技术网

Ios UICollectionView不允许完全滚动---最后几行被切断

Ios UICollectionView不允许完全滚动---最后几行被切断,ios,xcode,swift,uicollectionview,Ios,Xcode,Swift,Uicollectionview,我有一个UICollectionView,里面有一堆照片 但是,如果我滚动到底部,scrollview将不允许我滚动到最后几行的底部(它会回退)。我已经尝试覆盖collectionView.contentSize,只在高度上增加了1000,但没有解决问题 collectionView.contentSize=CGSizeMake(collectionView.contentSize.width,collectionView.contentSize.height+1000) 以下是问题的视频:

我有一个UICollectionView,里面有一堆照片

但是,如果我滚动到底部,scrollview将不允许我滚动到最后几行的底部(它会回退)。我已经尝试覆盖collectionView.contentSize,只在高度上增加了1000,但没有解决问题

collectionView.contentSize=CGSizeMake(collectionView.contentSize.width,collectionView.contentSize.height+1000)

以下是问题的视频:

以下是我创建单元格的代码:

    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
        {
            var cell = collectionView.dequeueReusableCellWithReuseIdentifier("selectPhotoCell", forIndexPath: indexPath) as B_SelectPhotoControllerViewCell
            let reuseCount = ++cell.reuseCount
            let asset = currentAssetAtIndex(indexPath.item)
            PHImageManager.defaultManager().requestImageForAsset(asset, targetSize:_cellSize, contentMode: .AspectFit, options: nil)//the target size here can be set to CGZero for a super blurry preview
            {
                result, info in
                if reuseCount == cell.reuseCount
                {
                    cell.imageView.image = result
                    cell.imageView.frame = CGRectMake(0, 0,self._cellSize.width,self._cellSize.height)
                }
            }
            return cell
        }


private func currentAssetAtIndex(index:NSInteger)->PHAsset
    {
        if let fetchResult = _assetsFetchResults
        {
            return fetchResult[index] as PHAsset
        }else
        {
            return _selectedAssets[index]
        }
    }
更新:


因为我将其添加为子视图控制器,所以scrollview的偏移似乎存在一些问题。我还没有修复它,但是当打开此视图而不将其作为子视图添加到另一个视图控制器时,scrollview的大小是正确的

问题是我将其作为子视图控制器添加


因此,在执行一些动画之后,UICollectionView边界将根据其所附着的视图调整大小。因此,它的高度是错误的,因此它被切断了。

我刚刚在谷歌上遇到了这个问题,我觉得我可以添加一些有用的东西

我正在运行一个带有UIView的分段控件,该控件在分段更改时会更改为不同的UICollectionView,因此我无法使collectionView完全向下滚动


这可能不是所有问题的解决方案,但我发现如果我转到我在视图中加载的XIB,并将大小设置为freeform,并将其减小到我已消除问题的单元格大小。

尝试关闭adjustScrollViewInsets(请参见示例:),我已关闭该选项,但问题仍然存在:(你是如何创建集合视图的?情节提要?你有适当的约束吗?它在情节提要中,我将每个边相对于父对象的边界设置为0,但我怀疑这里有什么问题!