Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.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 设备swift上的CollectionView重新加载数据问题_Ios_Swift - Fatal编程技术网

Ios 设备swift上的CollectionView重新加载数据问题

Ios 设备swift上的CollectionView重新加载数据问题,ios,swift,Ios,Swift,我正在尝试使用此代码重新加载collectionView的一些单元格 var indexPathsToReload = [NSIndexPath]() for var i in 0..<Data.NearByList.count { indexPathsToReload.append(NSIndexPath(forItem: i, inSection: 0)) } collview.reloadItemsAtInde

我正在尝试使用此代码重新加载collectionView的一些单元格

var indexPathsToReload = [NSIndexPath]()
        for var i in 0..<Data.NearByList.count {
            indexPathsToReload.append(NSIndexPath(forItem: i, inSection: 0))
        }

        collview.reloadItemsAtIndexPaths(indexPathsToReload)
`////更新 这是我的collectionview:cellforItemsatIndexPaths

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        // get a reference to our storyboard cell
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier(self.reuseIdentifier, forIndexPath: indexPath) as! CustomCollectionCell

        cell.UserID = Data.NearByList[Int(indexPath.item.value)].UserID

        cell.personImage.image=Data.UserIDImageMap[cell.UserID]
        cell.personImage.layer.cornerRadius=(cell.bounds.height-10) / 2.0

        if Data.NearByList[Int(indexPath.item.value)].Distance < 0.1 {
                cell.Location.text=String("0.0")+"\nkm"
        }
        else
        {
            cell.Location.text=String(Helpers.roundNumber(Data.NearByList[Int(indexPath.item.value)].Distance))+"\nkm"
        }




        if  Data.NearByList[Int(indexPath.item.value)].Selected == 1
        {
            cell.personImage.layer.borderColor = UIColor(rgb: 0x98cc00).CGColor
            cell.personImage.alpha=1
            cell.Location.textColor=UIColor.whiteColor()
            cell.LocationImage.image=UIImage(named: "SelectedPin.png")
        }
        else
        {
            cell.personImage.layer.borderColor = UIColor.grayColor().CGColor
            cell.personImage.alpha=0.5
            cell.Location.textColor=UIColor.grayColor()
            cell.LocationImage.image=UIImage(named: "UnSelectedPin.png")
        }



        cell.personImage.layer.borderWidth=3
        cell.personImage.layer.masksToBounds=true




        return cell
    }

但是有些单元格看起来不像圆形,我必须滚动才能使其正确。我想在索引路径处重新加载此单元格,出现此错误

您能发布更多代码吗? collview的类型是什么? 在上面的代码中,您是否看到选择器异常? 如果是,错误的选择器名称是哪一个? 我怀疑选择器问题与上述代码无关


如果我获得更多详细信息,将更新此答案:

我更新了它,我不知道是哪个选择器,我添加了整个异常
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        // get a reference to our storyboard cell
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier(self.reuseIdentifier, forIndexPath: indexPath) as! CustomCollectionCell

        cell.UserID = Data.NearByList[Int(indexPath.item.value)].UserID

        cell.personImage.image=Data.UserIDImageMap[cell.UserID]
        cell.personImage.layer.cornerRadius=(cell.bounds.height-10) / 2.0

        if Data.NearByList[Int(indexPath.item.value)].Distance < 0.1 {
                cell.Location.text=String("0.0")+"\nkm"
        }
        else
        {
            cell.Location.text=String(Helpers.roundNumber(Data.NearByList[Int(indexPath.item.value)].Distance))+"\nkm"
        }




        if  Data.NearByList[Int(indexPath.item.value)].Selected == 1
        {
            cell.personImage.layer.borderColor = UIColor(rgb: 0x98cc00).CGColor
            cell.personImage.alpha=1
            cell.Location.textColor=UIColor.whiteColor()
            cell.LocationImage.image=UIImage(named: "SelectedPin.png")
        }
        else
        {
            cell.personImage.layer.borderColor = UIColor.grayColor().CGColor
            cell.personImage.alpha=0.5
            cell.Location.textColor=UIColor.grayColor()
            cell.LocationImage.image=UIImage(named: "UnSelectedPin.png")
        }



        cell.personImage.layer.borderWidth=3
        cell.personImage.layer.masksToBounds=true




        return cell
    }
SwiftEventBus.onMainThread(self, name: "ReloadHomePage") { result in
            let id=result.object as! Int

            self.collview.reloadData()

           // self.collview.reloadItemsAtIndexPaths([NSIndexPath(forItem: id, inSection: 0)])


        }