Comments (8)
from animatingtableviewheader.
Hi @mahesh789 ,
I have a couple questions for you that might help to identify what is going on in your situation :)
-
Could you clarify what you mean by "estimate automatic"? Sounds like you are saying that it's disabled in my project but enabled in yours - but I'm not exactly sure what property you are referring to. Maybe a screenshot would help?
-
When you reload your table view, are you inserting/deleting cells? Do you change the scroll position when you reload?
Also, as a side note, viewWillAppear
may not be a great place for calling reloadData
. I suppose it depends on your situation, but viewDidAppear
may help a little in this specific scenario.
from animatingtableviewheader.
Please check your project in attachment file.
AnimatingTableViewHeader-master.zip
from animatingtableviewheader.
Thank you for the example project. I think i have a better idea of what is going on now.
You choose to size the cells using UITableViewAutomaticDimension
(which maps to these checkboxes here)
.
This in and of itself is not problematic, but I noticed that you also added the delegate method tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath)
and specified a hard coded height of 100
. As a result, as the table view tries to size itself according to the UITableViewAutomaticDimension
rules, it gives the cell only as much room (height wise) as it thinks the cell needs (in our case about 44 points). However, when it finally comes time to show the cell on the screen, your delegate method says, "No wait, I actually want the cell height to be 100
points!" As a result, the table view needs to resize itself and the scrollView.contentSize.height
changes.
This cause our math in the scrollViewDidScroll(_ scrollView: UIScrollView)
function to get messed up - specifically with the scrollDiff
variable. Because the height of the scroll view changed, the diff becomes inflated since the difference from the previous scroll position to the current scroll position is larger (about 56 points larger! 56 + 44 = 100). Finally, as a result, we see the header becoming "bouncy" as we scroll up and down the page.
Although I wouldn't recommend using UITableViewAutomaticDimension
AND setting the cell height to a specific value, you have pointed out an issue that is fixable in this example project. I'll update the code shortly and link back here the solution.
from animatingtableviewheader.
@mahesh789, I believe i've addressed your issue with the above commit. Specifically this line.
Let me know if you have any questions or if this didn't actually solve your issue.
Thanks!
from animatingtableviewheader.
from animatingtableviewheader.
from animatingtableviewheader.
if you reload only rows instead of complete section, issue will be resolved.
Just call this function with proper params like section old count and new count.
extension UITableView{
func reloadRowsInSection(section: Int, oldCount:Int, newCount: Int){
let maxCount = max(oldCount, newCount)
let minCount = min(oldCount, newCount)
var changed = [IndexPath]()
for i in minCount..<maxCount {
let indexPath = IndexPath(row: i, section: section)
changed.append(indexPath)
}
var reload = [IndexPath]()
for i in 0..<minCount{
let indexPath = IndexPath(row: i, section: section)
reload.append(indexPath)
}
beginUpdates()
if(newCount > oldCount){
insertRows(at: changed, with: .fade)
}else if(oldCount > newCount){
deleteRows(at: changed, with: .fade)
}
if(newCount > oldCount || newCount == oldCount){
insertRows(at: reload, with: .none)
}
endUpdates()
}
}
from animatingtableviewheader.
Related Issues (8)
- Bug with 2-3 rows HOT 2
- Search Bar does not always expand HOT 3
- FooterView not working HOT 3
- Getting the header to not expand until at the top of the TableView HOT 6
- Laggy header when scrolling tableview with image cell HOT 4
- isScrollingDown and isScrollingUp - appear in revserse HOT 4
- Header late to expand upon scroll up when table view has bottom layout margins or content inset
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from animatingtableviewheader.