Comments (11)
from amscrollingnavbar.
Didn't help me!
It doesn't work properly.
Actually I call the showNavbar
method in the action of segmentValueChanged
.
from amscrollingnavbar.
Hi @arashetm
I'm testing against the Demo project, attached the segment action like so:
@IBAction func segmentChange() {
if let navigationController = self.navigationController as? ScrollingNavigationController {
navigationController.showNavbar(animated: true, duration: 0.2, scrollToTop: true)
}
}
and it seems to be working fine. Can you share a sample project showing the issue?
from amscrollingnavbar.
I figured out what's the problem!
If I want to scroll to the top without changing segment it works like charm, but if I want to update my table view data source alongside scrolling to the top it doesn't work properly.
Here is my code:
@IBAction func segmentValueChanged(_ sender: UISegmentedControl) {
_ = self.scrollViewShouldScrollToTop(self.archiveTableView)
self.setBannersFrame() //setting table header view
// change table view's data based on the selected segment
self.reloadArchiveTableView() // reloading table view
}
I found a hacky slution for this::
@IBAction func segmentValueChanged(_ sender: UISegmentedControl) {
_ = self.scrollViewShouldScrollToTop(self.archiveTableView)
self.setBannersFrame() //setting table header view
// change table view's data based on the selected segment
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.reloadArchiveTableView() // reloading table view
}
}
Maybe you need to add completion handler for showNavbar
method.
from amscrollingnavbar.
Sounds good, checkout the latest master commit for the completion handler in showNavbar
from amscrollingnavbar.
It didn't work ...
from amscrollingnavbar.
I'm afraid it's still triggered too early, before UIKit rearranges the table
from amscrollingnavbar.
Do you have any suggestions?
Reloading should start exactly right after scroll did end scrolling, could we use scrollViewDidEndScrollingAnimation
?
I need to achieve this.
from amscrollingnavbar.
Checkout the updated demo in master, the tableview now scrolls to top and updates the data source, and it seems to be working. Maybe it helps, let me know
b280a88#diff-42fa19733453bd36493bea5901519e2d
from amscrollingnavbar.
Any feedback?
from amscrollingnavbar.
you can fix it by calling collectionview's scrolltoItem method in the completion block:
open func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
if let navigationController = self.navigationController as? ScrollingNavigationController {
navigationController.showNavbar(animated: false, duration: 0.1, scrollToTop: false) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
self.collectionView.scrollToItem(at: IndexPath(row: 0, section: 0), at: .top, animated: true)
}
}
}
return true
}
from amscrollingnavbar.
Related Issues (20)
- Live demo at https://appetize.io fails to get launched HOT 1
- Deprecated API Usage
- iOS 13 TabBar position is invalid after resuming device from lock HOT 1
- Table view buttons and title disappears after going back from full screen presented controller HOT 2
- Scroll to Top is not exact correct HOT 8
- Scroll when collapsed does not expand HOT 3
- Native SPM Support HOT 1
- Navigation bar isTranslucent = false is not working correctly HOT 2
- Can't not submit app to AppConnect since UIWebView is deprecated. HOT 2
- Container navigation controller breaks bar HOT 3
- Weird behaviour after accessing bottomLayoutGuide with iOS14 HOT 3
- Title goes beyond navigationbar on scrollEdge/compact appearance on IOS 13+
- Navigation bar background color changing HOT 6
- Navbar is not hiding in iOS 14 HOT 1
- iOS 15 Appearance issue HOT 1
- Fatal Exception: NSInternalInconsistencyException UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0xcf6b25b9e4f777ac> {length = 2, path = 0 - 2} HOT 1
- No more scrolling with iOS 15.1 HOT 10
- UITabbarController show space above navigationbar ios15
- Not Able to Scroll Up to the Top after Scrolling Down in iOS 15+ HOT 2
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 amscrollingnavbar.