많은 셀을 관리하는 UICollectionView가 있습니다. 셀을 삭제할 때 refreshControl을 사용하여 셀을 사라지게하고 싶습니다. 하지만 reloadData가 작동하지 않는 이유를 알지 못합니다. 누구든지 사전에 감사 드릴 수 있다면. 내보기 didLoad에서 refreshControl에서 reloadData()가 작동하지 않습니다.
:self.collectionView!.alwaysBounceVertical = true
let refresher = UIRefreshControl()
refresher.tintColor = MyColor.Color
refresher.addTarget(self, action: #selector(PublicListController.refreshStream), forControlEvents: .ValueChanged)
refreshControl = refresher
collectionView!.addSubview(refreshControl!)
collectionView.dataSource = self
self.populateDataBest()
내 단순히 기능 :
func populateDataBest() {
self.videosService.get(true, completionHandler: {
videosBest, error in
dispatch_async(dispatch_get_main_queue(), {
if error != nil {
if error!.code == -999 {
return
}
self.displayError(informations.LocalizedConnectionError)
return
}
self.bestClip = videosBest
for (indexBest, _) in (self.bestClip?.enumerate())! {
let videoBest:Clip = self.bestClip![indexBest]
self.pictureArrayVideo.addObject(["clip": videoBest, "group": "BEST"])
}
self.dataSource.updateData(self.pictureArrayVideo)
self.collectionView.reloadData()
})
})
}
그리고 상기 첫 번째 재 장전 작업 :
func refreshStream() {
collectionView?.reloadData()
refreshControl?.endRefreshing()
}
나는 방법 populateDataBest 내 CollectionView를 완료 내 메서드 populateDataBest ..의 끝
,210편집 : 내 요소
func refreshStream() {
dispatch_async(dispatch_get_main_queue(), {
self.remove(0)
self.collectionView.reloadData()
})
self.refreshControl.endRefreshing()
}
func remove(i: Int) {
self.listForPager.removeAtIndex(i)
let indexPath: NSIndexPath = NSIndexPath(forRow: i, inSection: 0)
self.collectionView.performBatchUpdates({
self.collectionView.deleteItemsAtIndexPaths(NSArray(object: indexPath) as! [NSIndexPath])
}, completion: {
(finished: Bool) in
self.collectionView.reloadItemsAtIndexPaths(self.collectionView.indexPathsForVisibleItems())
})
}
(난 그냥 그 순간 내 시험을 위해 제거 방법에 대한 매개 변수에 0을 넣어) 제거 기능을 구현하려고
그리고이 오류 후이
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (8) must be equal to the number of items contained in that section before the update (8), plus or minus the number of items inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'
누군가가 이유를 알고 PLZ 나를 도울 수 있습니까?
Thx.
"스위프트 IOS"를 제목에 추가 할 필요가 없습니다. 이미이 태그가 있습니다. –