Giter Club home page Giter Club logo

Comments (3)

FW1024 avatar FW1024 commented on June 9, 2024

This problem is resolved when a UIStackView exists between the UITextField and the UITableView.
How can I solve this problem without adding UIStackView.

 UIView.animate(withDuration: animationDuration, delay: 0, options: animationCurve, animations: { () -> Void in
    let animatedContentOffset = textFieldView.superviewOfClassType(UIStackView.self, belowView: scrollView) != nil  //  (Bug ID: #1365, #1508, #1541)

                                if animatedContentOffset {
                                    scrollView.setContentOffset(newContentOffset, animated: UIView.areAnimationsEnabled)
                                } else {
                                    scrollView.contentOffset = newContentOffset
                                }
                            }, completion: { _ in

                                if scrollView is UITableView || scrollView is UICollectionView {
                                    //This will update the next/previous states
                                    self.addToolbarIfRequired()
                                }
                            })

This code may be causing the malfunction

from iqkeyboardmanager.

hackiftekhar avatar hackiftekhar commented on June 9, 2024

I found out that it's due to animatedContentOffset and it depends on the UIStackView. The condition is there because of (Bug ID: #1365, #1508, #1541).

I also found out that when keyboard resign the same problem happen due to below code:-

            UIView.animate(withDuration: animationDuration, delay: 0, options: animationCurve, animations: { () -> Void in

                if lastScrollView.contentInset != self.startingContentInsets {
                    self.showLog("Restoring contentInset to: \(self.startingContentInsets)")
                    lastScrollView.contentInset = self.startingContentInsets
                    lastScrollView.scrollIndicatorInsets = self.startingScrollIndicatorInsets
                }

                if lastScrollView.shouldRestoreScrollViewContentOffset, !lastScrollView.contentOffset.equalTo(self.startingContentOffset) {
                    self.showLog("Restoring contentOffset to: \(self.startingContentOffset)")

                    let animatedContentOffset = self.textFieldView?.superviewOfClassType(UIStackView.self, belowView: lastScrollView) != nil  //  (Bug ID: #1365, #1508, #1541)

                    if animatedContentOffset {
                        lastScrollView.setContentOffset(self.startingContentOffset, animated: UIView.areAnimationsEnabled)
                    } else {
                        lastScrollView.contentOffset = self.startingContentOffset
                    }
                }
                //...
            })

When I debugged more, I found out that changing contentInset is producing weird behavior, but it's there for a reason and we can't remove it from there.

from iqkeyboardmanager.

hackiftekhar avatar hackiftekhar commented on June 9, 2024

I have added two more conditions there one is for UICollectionView and another one is for UITableView, so if it's there then setContentOffset function will be used. This fixed the animation when keyboard appears.

from iqkeyboardmanager.

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.