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
What Is Container View in iOS 5 Sdk
Gem Native Extension Error While Installing Cocoapods
How to Add a Character at a Particular Index in String in Swift
Best Way to Save and Retrieve Uicolors to Core Data
#Import <Libxml/Tree.H> File Not Found After Xcode Update
To Change the Color of Unselected Uitabbar Icon in iOS 7
Archs[@]: Unbound Variable in Xcode 12
Swift: Type Must Implement Protocol and Be a Subclass of Given Class
Passing Data with Segue Through Navigationcontroller
How to Disable Custom Keyboards (Ios8) for My App
Reload Section Without Reloading Section Header
How to Detect If the Currently Running App Was Installed from the App Store
Can Swift Closures Be Set to a Default Value When Used as a Parameter in a Function
Set Delegates to Nil Under Arc
Programmatically Creating Uilabel
How to Do Something Before Unwind Segue Action
Completely Disable Firebase/Analytics to Stop Console Spam on App Startup