Comments (7)
Okay. I did some testing.
I made it work by first of all implementing #75.
Then I created a var to hold the height of the navigation and status bar:
open var navigationControllerHeight: CGFloat = 0
Initially 0 to make it possible to just enable my "fix" by setting:
awesomeRefresher.navigationControllerHeight = (self.navigationController?.navigationBar.frame.size.height)! + UIApplication.shared.statusBarFrame.height
This way it works on both iPhone X and all the other ones, since the new iPhone has a different status bar.
I then use this variable here, adding it to the value of self.scrollViewDefaultInsets (which are 0):
func animateFinishedState() {
removeScrollViewObserving()
UIView.animate(
withDuration: animationDuration,
delay: hideDelay,
usingSpringWithDamping: springDamping,
initialSpringVelocity: initialSpringVelocity,
options: animationOptions,
animations: {
self.scrollView?.contentInset = self.scrollViewDefaultInsets
if case .top = self.position {
self.scrollView?.contentOffset.y = -(self.scrollViewDefaultInsets.top + self.navigationControllerHeight)
}
},
completion: { _ in
self.addScrollViewObserving()
self.state = .initial
}
)
}
And here, the same logic:
override open func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if (context == &PullToRefresh.KVOContext && keyPath == contentOffsetKeyPath && object as? UIScrollView == scrollView) {
var offset: CGFloat
switch position {
case .top:
offset = previousScrollViewOffset.y + scrollViewDefaultInsets.top + self.navigationControllerHeight ....
Because it seems the ContentInsets are always 0 when used inside a UITableViewController. Note that I still do:
self.automaticallyAdjustsScrollViewInsets = false
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0)
self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, 0)
To make it work.
If anyone has any idea how to properly implement this solution feel free to pitch in! I created a pull request that implements these changes and does so without breaking anything else: #77 It works on both iOS 11 and 10.
from pulltorefresh.
@nickdnk Hi! Thank for your report. Starting from iOS 11automaticallyAdjustsScrollViewInsets
is deprecated. Although, you have a something new in UIScrollView
: contentInsetAdjustmentBehavior, adjustedContentInset and adjustedContentInsetDidChange() method. So you must to set contentInsetAdjustmentBehavior = .never
instead of automaticallyAdjustsScrollViewInsets = false
and manually manage for your table view insets.
from pulltorefresh.
Hey @SerjOxo
Sorry I didn't get back on this. I just tried updating to 3.x and it's still very broken inside a UITableViewController. My own forked version still works fine for my use case so I'm using that for now.
I'll have a look at those news properties you mentioned and see if I can get it to work.
from pulltorefresh.
I cannot get 3.0 to work at all. Did you try to use it with a UITableViewController?
from pulltorefresh.
Hello
Still doesn't work inside UITableViewController on 3.0.2. Any news on this problem? I don't know what information you need from me to fix it (if you want to or can at all).
Let me know.
from pulltorefresh.
Hi @nickdnk!
Does it work correctly on the recent version?
from pulltorefresh.
Hello
Sorry for the "delay". Our focus has been elsewhere but I now need to update our app, which I cannot as the custom fork of the project I used only works in Swift 3 which is no longer supported.
It still does not work as expected. I now suffer from #124. Again on a UITableViewController subclass.
from pulltorefresh.
Related Issues (20)
- scrollView.contentOffset Error HOT 3
- Add Swift 4.2 support HOT 1
- Install 3.1.0 failed with CocoaPods HOT 3
- Opposite refresher is missing in a common scrolling case HOT 1
- The opposite refresher is missing HOT 2
- Problem in scrolling , when increas cell height 540 HOT 1
- Height didn't work when create a custom PullToRefresh. HOT 1
- Swift 5 update HOT 1
- Getting Crash HOT 1
- version 3.3 freeze the app and high cpu usage 100% HOT 2
- Invalid toppadding property value HOT 1
- Indicator not show on swipe or start refreshing HOT 2
- 'endRefreshing' is inaccessible due to 'internal' protection level HOT 1
- Supporting Swift Package Manager HOT 2
- Custom PullToRefresh is always visible at the top left corner HOT 2
- Why is the isEnabled property in the PullToRefresh.swift file default to false?
- Call endRefreshing(at: .top) has no effect HOT 2
- Crash on range bounds if refresh view height is greater than 1000
- Privacy manifest required by Apple
- Will this be updated to Swift 4? HOT 1
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 pulltorefresh.