Code Monkey home page Code Monkey logo

Comments (7)

nickdnk avatar nickdnk commented on June 3, 2024 1

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.

srj0x0 avatar srj0x0 commented on June 3, 2024

@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.

nickdnk avatar nickdnk commented on June 3, 2024

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.

nickdnk avatar nickdnk commented on June 3, 2024

I cannot get 3.0 to work at all. Did you try to use it with a UITableViewController?

from pulltorefresh.

nickdnk avatar nickdnk commented on June 3, 2024

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.

sergey-prikhodko avatar sergey-prikhodko commented on June 3, 2024

Hi @nickdnk!

Does it work correctly on the recent version?

from pulltorefresh.

nickdnk avatar nickdnk commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.