Uitableview UICollectionView在swift 3中不刷新

Uitableview UICollectionView在swift 3中不刷新,uitableview,swift3,uicollectionview,uicollectionviewcell,uicollectionviewlayout,Uitableview,Swift3,Uicollectionview,Uicollectionviewcell,Uicollectionviewlayout,我在我的应用程序中添加UICollectionView,每个单元格都有“删除”垃圾箱按钮。 当我点击这个按钮时,它会显示提示信息询问。单击“确定”按钮后,集合视图中的项目将被删除但是,用户界面不刷新,项目未被删除 我的代码是 override func viewDidLoad() { super.viewDidLoad() myCollectionView.reloadData() } override func viewDidAppear(_ animated: Bool)

我在我的应用程序中添加UICollectionView,每个单元格都有“删除”垃圾箱按钮。
当我点击这个按钮时,它会显示提示信息询问。单击“确定”按钮后,集合视图中的项目将被删除
但是,用户界面不刷新,项目未被删除
我的代码是

override func viewDidLoad() {
    super.viewDidLoad()
    myCollectionView.reloadData()

}

override func viewDidAppear(_ animated: Bool) {
    debugPrint("viewDidAppear")
    callWatchLater()
}

override func viewWillAppear(_ animated: Bool) {
    DispatchQueue.main.async(execute: {
        debugPrint("Appear")
        self.myCollectionView.reloadData()
    })


}

override func viewDidLayoutSubviews() {
    DispatchQueue.main.async(execute: {
        debugPrint("SubViews")
        self.myCollectionView.reloadData()
    })
}
警报控制器的代码为

 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "watchCell", for: indexPath) as! WatchLaterTableCell


        let watchTableList = self.watchLaterTable[indexPath.row]

        cell.deleteMovie.addTarget(self, action:#selector(showAlert(sender:)), for: .touchUpInside)


        }


        return cell
    }

func showAlert(sender:UIButton!)
    {
    debugPrint("Press Button")
    let alert = UIAlertController(title: "Are you really want to delete this movie?", message: "", preferredStyle: UIAlertControllerStyle.alert)



    // Create the actions
    let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default) {
        UIAlertAction in
        self.callRest()
        debugPrint("Press OK")


    }
    let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel) {
        UIAlertAction in

        _ = self.navigationController?.popViewController(animated: true)
    }


    // Add the actions
    alert.addAction(okAction)
    alert.addAction(cancelAction)


    // Present the controller

    DispatchQueue.main.async(execute: {
        self.present(alert, animated: true, completion: nil)
    })


}
callRest()的代码是



但是,CollectionView不会刷新。有人能帮我吗?

添加带有AlertController的删除按钮的操作您使用CollectionView时,什么是表不刷新?我单击删除按钮,会出现警告框,然后单击确定按钮。背景数组项列表已被扣除,但UI不是这样。你不明白我的问题是你正在使用collectionView,那么你为什么要谈论刷新tableView@NiravD对不起,兄弟。我打错了。我编辑这个问题。我的意思是UICollectionView bro。使用AlertController添加删除按钮的操作您的意思是什么?当您使用CollectionView时,表不刷新。我单击删除按钮,会出现警告框,然后单击确定按钮。背景数组项列表已被扣除,但UI不是这样。你不明白我的问题是你正在使用collectionView,那么你为什么要谈论刷新tableView@NiravD对不起,兄弟。我打错了。我编辑这个问题。我是说我的收藏观兄弟。
 func callRest(){
    SwiftLoading().showLoading()
    if Reachability().isInternetAvailable() == true {
        rest.auth(auth: access_token)
        rest.delete(StringResource().mainURL + "user/" + user_id + "/watch/later/" + String(vedioId) , parma: [:], finished: {(result: NSDictionary, status : Int) -> Void in

            debugPrint(result)

            if(status == 200){
                let data = result["data"] as! NSString
                self.messages = String(describing: data)


                DispatchQueue.main.sync{[unowned self] in


                    let alertController = UIAlertController(title: "", message: self.messages , preferredStyle: .alert)

                    // Create the actions
                    let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default) {
                        UIAlertAction in

                        debugPrint("call rest Press OK")
                        self.callWatchLaterGetAPI()
                     }

                    alertController.addAction(okAction)

                    // Present the controller
                    DispatchQueue.main.async(execute: {
                        self.present(alertController, animated: true, completion: nil)
                    })

                }
                self.myCollectionView.reloadData()
                SwiftLoading().hideLoading()
            }else{


                let error = result["error"] as! NSArray

                for item in 0...(error.count) - 1 {

                    let device : AnyObject = error[item] as AnyObject

                    self.messages = device["message"] as! String

                    DispatchQueue.main.sync{[unowned self] in

                    let alertController = UIAlertController(title: "", message: self.messages , preferredStyle: .alert)

                     // Create the actions
                    let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default) {
                            UIAlertAction in

                            debugPrint("Press OK")


                        }

                        alertController.addAction(okAction)

                        // Present the controller
                        DispatchQueue.main.async(execute: {
                            self.present(alertController, animated: true, completion: nil)
                        })
                    }

                    SwiftLoading().hideLoading()
                }
            }
        })

    }else{
        noInternetConnection()
    }
}