Reload Section Without Reloading Section Header

Reload tableView section without reloading header section - Swift

You could use UITableView's reloadSections method instead.

tableView.reloadSections(IndexSet(integer: 2), with: .none)

Reload header in section without reloading section rows in swift

let sectionIndex = IndexSet(integer: 0)
self.tableView.reloadSections(sectionIndex, with: .none)

You can reload the tableview with this code. You dont need to reload header for showing items

How to reload a section header without it disappearing/re-appearing in Swift?

Found a solution referenced by @Abhinav:

Reload tableview section without scroll or animation

Slight modification updated for Swift 3.0:

UIView.performWithoutAnimation {

self.tableView.beginUpdates()
self.tableView.reloadSections(indexSet, with: UITableViewRowAnimation.none)
self.tableView.endUpdates()

}

Now if I scroll past the number of visible cells on screen and I delete a row, the headerCell.theCountLabel.text in my section header is updated without any animation, and remains still.

How to update a custom section header without reloading the whole table view?

try reloadSections method :

In Swift

let sectionToReload = 1
let indexSet: IndexSet = [sectionToReload]

self.tableView.reloadSections(indexSet, with: .automatic)

In Objective c

- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation

Reload collectionview cells and not the section header

You may try to extract the sequence of IndexPath in a specific section, then call reloadItems on such sequence, doing so:

extension UICollectionView {
func reloadItems(inSection section:Int) {
reloadItems(at: (0..<numberOfItems(inSection: section)).map {
IndexPath(item: $0, section: section)
})
}
}

so your code might be something like:

var updateSection = 0 // whatever
collectionView.performBatchUpdates({
// modify here the collection view
// eg. with: collectionView.insertItems
// or: collectionView.deleteItems
}) { (success) in
collectionView.reloadItems(inSection: updateSection)
}


Related Topics



Leave a reply



Submit